Skip to content

Commit e7e9303

Browse files
committed
Auto merge of #88363 - michaelwoerister:remapped-diagnostics, r=estebank
Path remapping: Make behavior of diagnostics output dependent on presence of --remap-path-prefix. This PR fixes a regression (#87745) with `--remap-path-prefix` where the flag stopped causing diagnostic messages to be remapped as well. The regression was introduced in rust-lang/rust#83813 where we erroneously assumed that remapping of diagnostic messages was not desired anymore (because #70642 partially undid that functionality with nobody objecting). The issue is fixed by making `--remap-path-prefix` remap diagnostic messages again, including for paths that have been remapped in upstream crates (e.g. the standard library). This means that "sysroot-localization" (implemented in #70642) is also disabled if `rustc` is invoked with `--remap-path-prefix`. The assumption is that once someone starts explicitly remapping paths they also don't want paths to their local Rust installation in their build output. In the future we might want to give more fine-grained control over this behavior via compiler flags (see rust-lang/rfcs#3127 for a related RFC). For now this PR is intended as a regression fix. This PR is an alternative to rust-lang/rust#88191, which makes diagnostic messages be remapped unconditionally. That approach, however, would effectively revert #70642. Fixes rust-lang/rust#87745. cc `@cbeuw` r? `@ghost`
2 parents e604975 + 7753eda commit e7e9303

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/debuginfo/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<'tcx> DebugContext<'tcx> {
6666
rustc_interface::util::version_str().unwrap_or("unknown version"),
6767
cranelift_codegen::VERSION,
6868
);
69-
let comp_dir = tcx.sess.opts.working_dir.to_string_lossy(false).into_owned();
69+
let comp_dir = tcx.sess.opts.working_dir.to_string_lossy(FileNameDisplayPreference::Remapped).into_owned();
7070
let (name, file_info) = match tcx.sess.local_crate_source_file.clone() {
7171
Some(path) => {
7272
let name = path.to_string_lossy().into_owned();

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ mod vtable;
7474
mod prelude {
7575
pub(crate) use std::convert::{TryFrom, TryInto};
7676

77-
pub(crate) use rustc_span::Span;
77+
pub(crate) use rustc_span::{Span, FileNameDisplayPreference};
7878

7979
pub(crate) use rustc_hir::def_id::{DefId, LOCAL_CRATE};
8080
pub(crate) use rustc_middle::bug;

0 commit comments

Comments
 (0)