@@ -252,7 +252,8 @@ impl Session {
252252
253253 pub fn local_crate_source_file ( & self ) -> Option < PathBuf > {
254254 let path = self . io . input . opt_path ( ) ?;
255- if self . should_prefer_remapped_for_codegen ( ) {
255+ // FIXME: The remap path scope should probably not be hardcoded.
256+ if self . should_prefer_remapped ( RemapPathScopeComponents :: DEBUGINFO ) {
256257 Some ( self . opts . file_path_mapping ( ) . map_prefix ( path) . 0 . into_owned ( ) )
257258 } else {
258259 Some ( path. to_path_buf ( ) )
@@ -886,8 +887,8 @@ impl Session {
886887 self . opts . cg . link_dead_code . unwrap_or ( false )
887888 }
888889
889- pub fn should_prefer_remapped_for_codegen ( & self ) -> bool {
890- self . opts . unstable_opts . remap_path_scope . contains ( RemapPathScopeComponents :: DEBUGINFO )
890+ pub fn should_prefer_remapped ( & self , scope : RemapPathScopeComponents ) -> bool {
891+ self . opts . unstable_opts . remap_path_scope . contains ( scope )
891892 }
892893}
893894
@@ -1439,12 +1440,8 @@ pub trait RemapFileNameExt {
14391440
14401441 /// Returns a possibly remapped filename based on the passed scope and remap cli options.
14411442 ///
1442- /// One and only one scope should be passed to this method. For anything related to
1443- /// "codegen" see the [`RemapFileNameExt::for_codegen`] method.
1443+ /// One and only one scope should be passed to this method, it will panic otherwise.
14441444 fn for_scope ( & self , sess : & Session , scope : RemapPathScopeComponents ) -> Self :: Output < ' _ > ;
1445-
1446- /// Return a possibly remapped filename, to be used in "codegen" related parts.
1447- fn for_codegen ( & self , sess : & Session ) -> Self :: Output < ' _ > ;
14481445}
14491446
14501447impl RemapFileNameExt for rustc_span:: FileName {
@@ -1461,14 +1458,6 @@ impl RemapFileNameExt for rustc_span::FileName {
14611458 self . prefer_local ( )
14621459 }
14631460 }
1464-
1465- fn for_codegen ( & self , sess : & Session ) -> Self :: Output < ' _ > {
1466- if sess. should_prefer_remapped_for_codegen ( ) {
1467- self . prefer_remapped_unconditionaly ( )
1468- } else {
1469- self . prefer_local ( )
1470- }
1471- }
14721461}
14731462
14741463impl RemapFileNameExt for rustc_span:: RealFileName {
@@ -1485,12 +1474,4 @@ impl RemapFileNameExt for rustc_span::RealFileName {
14851474 self . local_path_if_available ( )
14861475 }
14871476 }
1488-
1489- fn for_codegen ( & self , sess : & Session ) -> Self :: Output < ' _ > {
1490- if sess. should_prefer_remapped_for_codegen ( ) {
1491- self . remapped_path_if_available ( )
1492- } else {
1493- self . local_path_if_available ( )
1494- }
1495- }
14961477}
0 commit comments