diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 87272b1605b79..7bb95ec05c557 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -1318,7 +1318,7 @@ impl EmitterWriter { buffer_msg_line_offset, &format!( "{}:{}:{}", - loc.file.name.prefer_local(), + loc.file.name.prefer_remapped(), sm.doctest_offset_line(&loc.file.name, loc.line), loc.col.0 + 1, ), @@ -1332,7 +1332,7 @@ impl EmitterWriter { 0, &format!( "{}:{}:{}: ", - loc.file.name.prefer_local(), + loc.file.name.prefer_remapped(), sm.doctest_offset_line(&loc.file.name, loc.line), loc.col.0 + 1, ), @@ -1356,12 +1356,12 @@ impl EmitterWriter { }; format!( "{}:{}{}", - annotated_file.file.name.prefer_local(), + annotated_file.file.name.prefer_remapped(), sm.doctest_offset_line(&annotated_file.file.name, first_line.line_index), col ) } else { - format!("{}", annotated_file.file.name.prefer_local()) + format!("{}", annotated_file.file.name.prefer_remapped()) }; buffer.append(buffer_msg_line_offset + 1, &loc, Style::LineAndColumn); for _ in 0..max_line_num_len { diff --git a/src/test/ui/remap-path-prefix.rs b/src/test/ui/remap-path-prefix.rs new file mode 100644 index 0000000000000..66a397bc7dbef --- /dev/null +++ b/src/test/ui/remap-path-prefix.rs @@ -0,0 +1,5 @@ +// compile-flags: --remap-path-prefix={{src-base}}=remapped + +fn main() { + ferris //~ ERROR cannot find value `ferris` in this scope +} diff --git a/src/test/ui/remap-path-prefix.stderr b/src/test/ui/remap-path-prefix.stderr new file mode 100644 index 0000000000000..a20cf6b4df80e --- /dev/null +++ b/src/test/ui/remap-path-prefix.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find value `ferris` in this scope + --> remapped/remap-path-prefix.rs:4:5 + | +LL | ferris + | ^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`.