@@ -42,7 +42,7 @@ pub(crate) struct DebugContext {
4242 namespace_map : DefIdMap < UnitEntryId > ,
4343 array_size_type : UnitEntryId ,
4444
45- should_remap_filepaths : bool ,
45+ filename_display_preference : FileNameDisplayPreference ,
4646}
4747
4848pub ( crate ) struct FunctionDebugContext {
@@ -84,22 +84,18 @@ impl DebugContext {
8484
8585 let mut dwarf = DwarfUnit :: new ( encoding) ;
8686
87- let should_remap_filepaths = tcx. sess . should_prefer_remapped_for_codegen ( ) ;
87+ use rustc_session:: config:: RemapPathScopeComponents ;
88+
89+ let filename_display_preference =
90+ tcx. sess . filename_display_preference ( RemapPathScopeComponents :: DEBUGINFO ) ;
8891
8992 let producer = producer ( tcx. sess ) ;
90- let comp_dir = tcx
91- . sess
92- . opts
93- . working_dir
94- . to_string_lossy ( if should_remap_filepaths {
95- FileNameDisplayPreference :: Remapped
96- } else {
97- FileNameDisplayPreference :: Local
98- } )
99- . into_owned ( ) ;
93+ let comp_dir =
94+ tcx. sess . opts . working_dir . to_string_lossy ( filename_display_preference) . to_string ( ) ;
95+
10096 let ( name, file_info) = match tcx. sess . local_crate_source_file ( ) {
10197 Some ( path) => {
102- let name = path. to_string_lossy ( ) . into_owned ( ) ;
98+ let name = path. to_string_lossy ( filename_display_preference ) . to_string ( ) ;
10399 ( name, None )
104100 }
105101 None => ( tcx. crate_name ( LOCAL_CRATE ) . to_string ( ) , None ) ,
@@ -156,7 +152,7 @@ impl DebugContext {
156152 stack_pointer_register,
157153 namespace_map : DefIdMap :: default ( ) ,
158154 array_size_type,
159- should_remap_filepaths ,
155+ filename_display_preference ,
160156 }
161157 }
162158
0 commit comments