@@ -21,7 +21,7 @@ use rustc_hir::def::DefKind;
2121use rustc_hir:: def_id:: DefIdMap ;
2222use rustc_session:: Session ;
2323use rustc_session:: config:: DebugInfo ;
24- use rustc_span:: { FileNameDisplayPreference , SourceFileHash , StableSourceFileId } ;
24+ use rustc_span:: { RemapPathScopeComponents , SourceFileHash , StableSourceFileId } ;
2525use rustc_target:: callconv:: FnAbi ;
2626
2727pub ( crate ) use self :: emit:: { DebugReloc , DebugRelocName } ;
@@ -44,7 +44,6 @@ pub(crate) struct DebugContext {
4444 namespace_map : DefIdMap < UnitEntryId > ,
4545 array_size_type : UnitEntryId ,
4646
47- filename_display_preference : FileNameDisplayPreference ,
4847 embed_source : bool ,
4948}
5049
@@ -102,18 +101,18 @@ impl DebugContext {
102101
103102 let mut dwarf = DwarfUnit :: new ( encoding) ;
104103
105- use rustc_session:: config:: RemapPathScopeComponents ;
106-
107- let filename_display_preference =
108- tcx. sess . filename_display_preference ( RemapPathScopeComponents :: DEBUGINFO ) ;
109-
110104 let producer = producer ( tcx. sess ) ;
111- let comp_dir =
112- tcx. sess . opts . working_dir . to_string_lossy ( filename_display_preference) . to_string ( ) ;
105+ let comp_dir = tcx
106+ . sess
107+ . source_map ( )
108+ . working_dir ( )
109+ . path ( RemapPathScopeComponents :: DEBUGINFO )
110+ . to_string_lossy ( ) ;
113111
114112 let ( name, file_info) = match tcx. sess . local_crate_source_file ( ) {
115113 Some ( path) => {
116- let name = path. to_string_lossy ( filename_display_preference) . to_string ( ) ;
114+ let name =
115+ path. path ( RemapPathScopeComponents :: DEBUGINFO ) . to_string_lossy ( ) . into_owned ( ) ;
117116 ( name, None )
118117 }
119118 None => ( tcx. crate_name ( LOCAL_CRATE ) . to_string ( ) , None ) ,
@@ -137,7 +136,7 @@ impl DebugContext {
137136
138137 {
139138 let name = dwarf. strings . add ( format ! ( "{name}/@/{cgu_name}" ) ) ;
140- let comp_dir = dwarf. strings . add ( comp_dir) ;
139+ let comp_dir = dwarf. strings . add ( & * comp_dir) ;
141140
142141 let root = dwarf. unit . root ( ) ;
143142 let root = dwarf. unit . get_mut ( root) ;
@@ -175,7 +174,6 @@ impl DebugContext {
175174 stack_pointer_register,
176175 namespace_map : DefIdMap :: default ( ) ,
177176 array_size_type,
178- filename_display_preference,
179177 embed_source,
180178 } )
181179 }
0 commit comments