Skip to content

Commit 5b31e00

Browse files
committed
Explicitly remap translated real path
1 parent fde286a commit 5b31e00

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
@@ -1637,7 +1637,22 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
16371637
virtual_name.display(),
16381638
new_path.display(),
16391639
);
1640-
let new_name = rustc_span::RealFileName::LocalPath(new_path);
1640+
1641+
// Check if the translated real path is affected by any user-requested
1642+
// remaps via --remap-path-prefix. Apply them if so.
1643+
// Note that this is a special case for imported rust-src paths specified by
1644+
// https://rust-lang.github.io/rfcs/3127-trim-paths.html#handling-sysroot-paths.
1645+
// Other imported paths are not currently remapped (see #66251).
1646+
let (user_remapped, applied) =
1647+
sess.source_map().path_mapping().map_prefix(&new_path);
1648+
let new_name = if applied {
1649+
rustc_span::RealFileName::Remapped {
1650+
local_path: Some(new_path.clone()),
1651+
virtual_name: user_remapped.to_path_buf(),
1652+
}
1653+
} else {
1654+
rustc_span::RealFileName::LocalPath(new_path)
1655+
};
16411656
*old_name = new_name;
16421657
}
16431658
}

0 commit comments

Comments
 (0)