Skip to content

Commit 2406e2f

Browse files
committed
Explicitly remap translated real path
1 parent 100af45 commit 2406e2f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

compiler/rustc_metadata/src/rmeta/decoder.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,22 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
16501650
virtual_name.display(),
16511651
new_path.display(),
16521652
);
1653-
let new_name = rustc_span::RealFileName::LocalPath(new_path);
1653+
1654+
// Check if the translated real path is affected by any user-requested
1655+
// remaps via --remap-path-prefix. Apply them if so.
1656+
// Note that this is a special case for imported rust-src paths specified by
1657+
// https://rust-lang.github.io/rfcs/3127-trim-paths.html#handling-sysroot-paths.
1658+
// Other imported paths are not currently remapped (see #66251).
1659+
let (user_remapped, applied) =
1660+
sess.source_map().path_mapping().map_prefix(&new_path);
1661+
let new_name = if applied {
1662+
rustc_span::RealFileName::Remapped {
1663+
local_path: Some(new_path.clone()),
1664+
virtual_name: user_remapped.to_path_buf(),
1665+
}
1666+
} else {
1667+
rustc_span::RealFileName::LocalPath(new_path)
1668+
};
16541669
*old_name = new_name;
16551670
}
16561671
}

0 commit comments

Comments
 (0)