@@ -26,11 +26,11 @@ use rustc_middle::ty::fast_reject::{self, TreatParams};
2626use rustc_middle:: ty:: { AssocItemContainer , SymbolName } ;
2727use rustc_middle:: { bug, span_bug} ;
2828use rustc_serialize:: { Decodable , Decoder , Encodable , Encoder , opaque} ;
29- use rustc_session:: config:: { CrateType , OptLevel , TargetModifier } ;
29+ use rustc_session:: config:: { CrateType , OptLevel , RemapPathScopeComponents , TargetModifier } ;
3030use rustc_span:: hygiene:: HygieneEncodeContext ;
3131use rustc_span:: {
32- ExternalSource , FileName , SourceFile , SpanData , SpanEncoder , StableSourceFileId , SyntaxContext ,
33- sym,
32+ ExternalSource , FileName , FileNameDisplayPreference , SourceFile , SpanData , SpanEncoder ,
33+ StableSourceFileId , SyntaxContext , sym,
3434} ;
3535use tracing:: { debug, instrument, trace} ;
3636
@@ -520,6 +520,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
520520 let source_map = self . tcx . sess . source_map ( ) ;
521521 let all_source_files = source_map. files ( ) ;
522522
523+ let filename_display_preference =
524+ self . tcx . sess . filename_display_preference ( RemapPathScopeComponents :: DEBUGINFO ) ;
525+
523526 // By replacing the `Option` with `None`, we ensure that we can't
524527 // accidentally serialize any more `Span`s after the source map encoding
525528 // is done.
@@ -551,11 +554,18 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
551554
552555 match source_file. name {
553556 FileName :: Real ( ref original_file_name) => {
554- // FIXME: This should probably to conditionally remapped under
555- // a RemapPathScopeComponents but which one?
556- let adapted_file_name = source_map
557- . path_mapping ( )
558- . to_embeddable_absolute_path ( original_file_name. clone ( ) , working_directory) ;
557+ let adapted_file_name =
558+ if filename_display_preference == FileNameDisplayPreference :: Remapped {
559+ source_map. path_mapping ( ) . to_embeddable_absolute_path (
560+ original_file_name. clone ( ) ,
561+ working_directory,
562+ )
563+ } else {
564+ source_map. path_mapping ( ) . to_local_embeddable_absolute_path (
565+ original_file_name. clone ( ) ,
566+ working_directory,
567+ )
568+ } ;
559569
560570 adapted_source_file. name = FileName :: Real ( adapted_file_name) ;
561571 }
0 commit comments