From eccc9e66287d5fd141e458ae3ab25ac96a567972 Mon Sep 17 00:00:00 2001 From: Urgau Date: Wed, 23 Aug 2023 15:46:58 +0200 Subject: [RFC 3127 - Trim Paths]: Condition remapped filepath on remap scopes --- compiler/rustc_metadata/src/rmeta/encoder.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'compiler/rustc_metadata/src') diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index dee2326ae32..e949e4670e2 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -525,9 +525,17 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { // the remapped version -- as is necessary for reproducible builds. let mut source_file = match source_file.name { FileName::Real(ref original_file_name) => { - let adapted_file_name = source_map - .path_mapping() - .to_embeddable_absolute_path(original_file_name.clone(), working_directory); + let adapted_file_name = if self.tcx.sess.should_prefer_remapped_for_codegen() { + source_map.path_mapping().to_embeddable_absolute_path( + original_file_name.clone(), + working_directory, + ) + } else { + source_map.path_mapping().to_local_embeddable_absolute_path( + original_file_name.clone(), + working_directory, + ) + }; if adapted_file_name != *original_file_name { let mut adapted: SourceFile = (**source_file).clone(); -- cgit 1.4.1-3-g733a5