@@ -554,13 +554,16 @@ pub fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) ->
554554    )  -> & ' ll  DIFile  { 
555555        debug ! ( ?source_file. name) ; 
556556
557-         use  rustc_session:: RemapFileNameExt ; 
557+         let  filename_display_preference =
558+             cx. sess ( ) . filename_display_preference ( RemapPathScopeComponents :: DEBUGINFO ) ; 
559+ 
560+         use  rustc_session:: config:: RemapPathScopeComponents ; 
558561        let  ( directory,  file_name)  = match  & source_file. name  { 
559562            FileName :: Real ( filename)  => { 
560563                let  working_directory = & cx. sess ( ) . opts . working_dir ; 
561564                debug ! ( ?working_directory) ; 
562565
563-                 if  cx . sess ( ) . should_prefer_remapped_for_codegen ( )  { 
566+                 if  filename_display_preference ==  FileNameDisplayPreference :: Remapped  { 
564567                    let  filename = cx
565568                        . sess ( ) 
566569                        . source_map ( ) 
@@ -623,7 +626,7 @@ pub fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) ->
623626            } 
624627            other => { 
625628                debug ! ( ?other) ; 
626-                 ( "" . into ( ) ,  other. for_codegen ( cx . sess ( ) ) . to_string_lossy ( ) . into_owned ( ) ) 
629+                 ( "" . into ( ) ,  other. display ( filename_display_preference ) . to_string ( ) ) 
627630            } 
628631        } ; 
629632
@@ -832,9 +835,11 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
832835    codegen_unit_name :  & str , 
833836    debug_context :  & CodegenUnitDebugContext < ' ll ,  ' tcx > , 
834837)  -> & ' ll  DIDescriptor  { 
838+     use  rustc_session:: { config:: RemapPathScopeComponents ,  RemapFileNameExt } ; 
835839    let  mut  name_in_debuginfo = tcx
836840        . sess 
837841        . local_crate_source_file ( ) 
842+         . map ( |src| src. for_scope ( & tcx. sess ,  RemapPathScopeComponents :: DEBUGINFO ) . to_path_buf ( ) ) 
838843        . unwrap_or_else ( || PathBuf :: from ( tcx. crate_name ( LOCAL_CRATE ) . as_str ( ) ) ) ; 
839844
840845    // To avoid breaking split DWARF, we need to ensure that each codegen unit 
@@ -862,30 +867,29 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
862867    // FIXME(#41252) Remove "clang LLVM" if we can get GDB and LLVM to play nice. 
863868    let  producer = format ! ( "clang LLVM ({rustc_producer})" ) ; 
864869
865-     use  rustc_session:: RemapFileNameExt ; 
866870    let  name_in_debuginfo = name_in_debuginfo. to_string_lossy ( ) ; 
867-     let  work_dir = tcx. sess . opts . working_dir . for_codegen ( tcx. sess ) . to_string_lossy ( ) ; 
871+     let  work_dir = tcx
872+         . sess 
873+         . opts 
874+         . working_dir 
875+         . for_scope ( tcx. sess ,  RemapPathScopeComponents :: DEBUGINFO ) 
876+         . to_string_lossy ( ) ; 
868877    let  output_filenames = tcx. output_filenames ( ( ) ) ; 
869-     let  split_name = if  tcx. sess . target_can_use_split_dwarf ( )  { 
870-         output_filenames
871-             . split_dwarf_path ( 
872-                 tcx. sess . split_debuginfo ( ) , 
873-                 tcx. sess . opts . unstable_opts . split_dwarf_kind , 
874-                 Some ( codegen_unit_name) , 
875-             ) 
876-             // We get a path relative to the working directory from split_dwarf_path 
877-             . map ( |f| { 
878-                 if  tcx. sess . should_prefer_remapped_for_split_debuginfo_paths ( )  { 
879-                     tcx. sess . source_map ( ) . path_mapping ( ) . map_prefix ( f) . 0 
880-                 }  else  { 
881-                     f. into ( ) 
882-                 } 
883-             } ) 
878+     let  split_name = if  tcx. sess . target_can_use_split_dwarf ( ) 
879+         && let  Some ( f)  = output_filenames. split_dwarf_path ( 
880+             tcx. sess . split_debuginfo ( ) , 
881+             tcx. sess . opts . unstable_opts . split_dwarf_kind , 
882+             Some ( codegen_unit_name) , 
883+         )  { 
884+         // We get a path relative to the working directory from split_dwarf_path 
885+         Some ( tcx. sess . source_map ( ) . path_mapping ( ) . to_real_filename ( f) ) 
884886    }  else  { 
885887        None 
886-     } 
887-     . unwrap_or_default ( ) ; 
888-     let  split_name = split_name. to_str ( ) . unwrap ( ) ; 
888+     } ; 
889+     let  split_name = split_name
890+         . as_ref ( ) 
891+         . map ( |f| f. for_scope ( tcx. sess ,  RemapPathScopeComponents :: DEBUGINFO ) . to_string_lossy ( ) ) 
892+         . unwrap_or_default ( ) ; 
889893    let  kind = DebugEmissionKind :: from_generic ( tcx. sess . opts . debuginfo ) ; 
890894
891895    let  dwarf_version =
0 commit comments