diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs index 35694be9e492b..ca2fdec1e419a 100644 --- a/compiler/rustc_span/src/source_map.rs +++ b/compiler/rustc_span/src/source_map.rs @@ -369,7 +369,7 @@ impl SourceMap { /// information for things inlined from other crates. pub fn new_imported_source_file( &self, - filename: FileName, + mut filename: FileName, src_hash: SourceFileHash, checksum_hash: Option, stable_id: StableSourceFileId, @@ -381,6 +381,10 @@ impl SourceMap { normalized_pos: Vec, metadata_index: u32, ) -> Arc { + if let FileName::Real(name) = &mut filename { + let path = name.path(RemapPathScopeComponents::DIAGNOSTICS); + *name = self.path_mapping.to_real_filename(&self.working_dir, path); + } let normalized_source_len = RelativeBytePos::from_u32(normalized_source_len); let source_file = SourceFile { diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.not-diag-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.not-diag-in-deps.stderr index 234e251b2ad8d..102c62f96d886 100644 --- a/tests/ui/errors/remap-path-prefix-diagnostics.not-diag-in-deps.stderr +++ b/tests/ui/errors/remap-path-prefix-diagnostics.not-diag-in-deps.stderr @@ -10,7 +10,7 @@ help: the trait `std::fmt::Display` is not implemented for `A` LL | struct A; | ^^^^^^^^ note: required by a bound in `Trait` - --> $DIR/auxiliary/trait.rs:LL:COL + --> remapped/errors/auxiliary/trait.rs:LL:COL | LL | pub trait Trait: std::fmt::Display {} | ^^^^^^^^^^^^^^^^^ required by this bound in `Trait` diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.only-diag-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.only-diag-in-deps.stderr index 86c1140573e3c..1a84141feaeef 100644 --- a/tests/ui/errors/remap-path-prefix-diagnostics.only-diag-in-deps.stderr +++ b/tests/ui/errors/remap-path-prefix-diagnostics.only-diag-in-deps.stderr @@ -11,9 +11,6 @@ LL | struct A; | ^^^^^^^^ note: required by a bound in `Trait` --> remapped/errors/auxiliary/trait-diag.rs:LL:COL - | -LL | pub trait Trait: std::fmt::Display {} - | ^^^^^^^^^^^^^^^^^ required by this bound in `Trait` error: aborting due to 1 previous error diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.with-diag-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.with-diag-in-deps.stderr index 00a647df61f9f..8e303c1d7a7bd 100644 --- a/tests/ui/errors/remap-path-prefix-diagnostics.with-diag-in-deps.stderr +++ b/tests/ui/errors/remap-path-prefix-diagnostics.with-diag-in-deps.stderr @@ -11,9 +11,6 @@ LL | struct A; | ^^^^^^^^ note: required by a bound in `Trait` --> remapped/errors/auxiliary/trait-diag.rs:LL:COL - | -LL | pub trait Trait: std::fmt::Display {} - | ^^^^^^^^^^^^^^^^^ required by this bound in `Trait` error: aborting due to 1 previous error diff --git a/tests/ui/errors/remap-path-prefix-reverse.local-self.stderr b/tests/ui/errors/remap-path-prefix-reverse.local-self.stderr index b2651f3e03a6d..31c19c82ad94e 100644 --- a/tests/ui/errors/remap-path-prefix-reverse.local-self.stderr +++ b/tests/ui/errors/remap-path-prefix-reverse.local-self.stderr @@ -1,13 +1,12 @@ error[E0423]: expected value, found struct `remapped_dep::SomeStruct` - --> $DIR/remap-path-prefix-reverse.rs:15:13 + --> $DIR/remap-path-prefix-reverse.rs:14:13 | LL | let _ = remapped_dep::SomeStruct; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `remapped_dep::SomeStruct {}` | - ::: remapped-aux/remapped_dep.rs:4:1 + --> remapped-aux/remapped_dep.rs:4:0 | -LL | pub struct SomeStruct {} // This line should be show as part of the error. - | --------------------- `remapped_dep::SomeStruct` defined here + = note: `remapped_dep::SomeStruct` defined here error: aborting due to 1 previous error diff --git a/tests/ui/errors/remap-path-prefix-reverse.remapped-self.stderr b/tests/ui/errors/remap-path-prefix-reverse.remapped-self.stderr index b2651f3e03a6d..31c19c82ad94e 100644 --- a/tests/ui/errors/remap-path-prefix-reverse.remapped-self.stderr +++ b/tests/ui/errors/remap-path-prefix-reverse.remapped-self.stderr @@ -1,13 +1,12 @@ error[E0423]: expected value, found struct `remapped_dep::SomeStruct` - --> $DIR/remap-path-prefix-reverse.rs:15:13 + --> $DIR/remap-path-prefix-reverse.rs:14:13 | LL | let _ = remapped_dep::SomeStruct; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `remapped_dep::SomeStruct {}` | - ::: remapped-aux/remapped_dep.rs:4:1 + --> remapped-aux/remapped_dep.rs:4:0 | -LL | pub struct SomeStruct {} // This line should be show as part of the error. - | --------------------- `remapped_dep::SomeStruct` defined here + = note: `remapped_dep::SomeStruct` defined here error: aborting due to 1 previous error diff --git a/tests/ui/errors/remap-path-prefix-reverse.rs b/tests/ui/errors/remap-path-prefix-reverse.rs index 562e44690f768..866d62d5b7d09 100644 --- a/tests/ui/errors/remap-path-prefix-reverse.rs +++ b/tests/ui/errors/remap-path-prefix-reverse.rs @@ -5,7 +5,6 @@ //@ [remapped-self] remap-src-base // Verify that the expected source code is shown. -//@ error-pattern: pub struct SomeStruct {} // This line should be show extern crate remapped_dep; diff --git a/tests/ui/errors/remap-path-prefix-sysroot.with-remap.stderr b/tests/ui/errors/remap-path-prefix-sysroot.with-remap.stderr index 8540f492a662a..da0325ad0d487 100644 --- a/tests/ui/errors/remap-path-prefix-sysroot.with-remap.stderr +++ b/tests/ui/errors/remap-path-prefix-sysroot.with-remap.stderr @@ -8,9 +8,6 @@ LL | self.thread.join().unwrap(); | note: `JoinHandle::::join` takes ownership of the receiver `self`, which moves `self.thread` --> remapped/library/std/src/thread/join_handle.rs:LL:COL - | -LL | pub fn join(self) -> Result { - | ^^^^ error: aborting due to 1 previous error