Skip to content

Commit

Permalink
Auto merge of #88363 - michaelwoerister:remapped-diagnostics, r=estebank
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
bors committed Sep 3, 2021
2 parents 78bf4ac + c6c1f32 commit a0152da
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions clippy_lints/src/macro_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit a0152da

Please sign in to comment.