diff options
| author | bors <bors@rust-lang.org> | 2021-09-03 00:23:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-09-03 00:23:10 +0000 |
| commit | 97f2698484c2d668b2f356a6c2252e5f08472234 (patch) | |
| tree | 209632109616122d110c477a33d4f13b0f623e15 /src | |
| parent | 371f3cd3fe523d0b398ed1db1620667c53ba7d02 (diff) | |
| parent | c296c89be601a57597a1c262b9e3a4c9b4d056cf (diff) | |
| download | rust-97f2698484c2d668b2f356a6c2252e5f08472234.tar.gz rust-97f2698484c2d668b2f356a6c2252e5f08472234.zip | |
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 https://github.com/rust-lang/rust/pull/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 https://github.com/rust-lang/rfcs/pull/3127 for a related RFC). For now this PR is intended as a regression fix. This PR is an alternative to https://github.com/rust-lang/rust/pull/88191, which makes diagnostic messages be remapped unconditionally. That approach, however, would effectively revert #70642. Fixes https://github.com/rust-lang/rust/issues/87745. cc `@cbeuw` r? `@ghost`
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/remap-path-prefix.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/remap-path-prefix.stderr | 9 | ||||
| -rw-r--r-- | src/tools/clippy/clippy_lints/src/macro_use.rs | 7 |
3 files changed, 20 insertions, 5 deletions
diff --git a/src/test/ui/remap-path-prefix.rs b/src/test/ui/remap-path-prefix.rs new file mode 100644 index 00000000000..2eef9709977 --- /dev/null +++ b/src/test/ui/remap-path-prefix.rs @@ -0,0 +1,9 @@ +// compile-flags: --remap-path-prefix={{src-base}}=remapped + +fn main() { + // We cannot actually put an ERROR marker here because + // the file name in the error message is not what the + // test framework expects (since the filename gets remapped). + // We still test the expected error in the stderr file. + ferris +} diff --git a/src/test/ui/remap-path-prefix.stderr b/src/test/ui/remap-path-prefix.stderr new file mode 100644 index 00000000000..ad6a35d1256 --- /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:8:5 + | +LL | ferris + | ^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/tools/clippy/clippy_lints/src/macro_use.rs b/src/tools/clippy/clippy_lints/src/macro_use.rs index a371f8bbd3c..39f7ade3f81 100644 --- a/src/tools/clippy/clippy_lints/src/macro_use.rs +++ b/src/tools/clippy/clippy_lints/src/macro_use.rs @@ -47,11 +47,8 @@ pub struct MacroRefData { impl MacroRefData { pub fn new(name: String, callee: Span, cx: &LateContext<'_>) -> Self { - let mut path = cx - .sess() - .source_map() - .span_to_filename(callee) - .prefer_local() + let sm = cx.sess().source_map(); + let mut path = sm.filename_for_diagnostics(&sm.span_to_filename(callee)) .to_string(); // std lib paths are <::std::module::file type> |
