Skip to content

Commit 1ced98a

Browse files
committed
Remap after prepending cwd
1 parent b76ce69 commit 1ced98a

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

Diff for: compiler/rustc_metadata/src/rmeta/encoder.rs

+16-5
Original file line numberDiff line numberDiff line change
@@ -497,11 +497,22 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
497497
let working_dir = &self.tcx.sess.working_dir;
498498
match working_dir {
499499
RealFileName::LocalPath(absolute) => {
500-
// If working_dir has not been remapped, then we emit a
501-
// LocalPath variant as it's likely to be a valid path
502-
RealFileName::LocalPath(
503-
Path::new(absolute).join(path_to_file),
504-
)
500+
// Although neither working_dir or the file name were subject
501+
// to path remapping, the concatenation between the two may
502+
// be. Hence we need to do a remapping here.
503+
let joined = Path::new(absolute).join(path_to_file);
504+
let (joined, remapped) =
505+
source_map.path_mapping().map_prefix(joined);
506+
if remapped {
507+
RealFileName::Remapped {
508+
local_path: None,
509+
virtual_name: joined,
510+
}
511+
} else {
512+
RealFileName::LocalPath(
513+
Path::new(absolute).join(path_to_file),
514+
)
515+
}
505516
}
506517
RealFileName::Remapped { local_path: _, virtual_name } => {
507518
// If working_dir has been remapped, then we emit

0 commit comments

Comments
 (0)