@@ -1524,16 +1524,25 @@ pub trait RemapFileNameExt {
15241524 where
15251525 Self : ' a ;
15261526
1527- fn for_scope ( & self , sess : & Session , scopes : RemapPathScopeComponents ) -> Self :: Output < ' _ > ;
1527+ /// Returns a possibly remapped filename based on the passed scope and remap cli options.
1528+ ///
1529+ /// One and only one scope should be passed to this method. For anything related to
1530+ /// "codegen" see the [`RemapFileNameExt::for_codegen`] method.
1531+ fn for_scope ( & self , sess : & Session , scope : RemapPathScopeComponents ) -> Self :: Output < ' _ > ;
15281532
1533+ /// Return a possibly remapped filename, to be used in "codegen" related parts.
15291534 fn for_codegen ( & self , sess : & Session ) -> Self :: Output < ' _ > ;
15301535}
15311536
15321537impl RemapFileNameExt for rustc_span:: FileName {
15331538 type Output < ' a > = rustc_span:: FileNameDisplay < ' a > ;
15341539
1535- fn for_scope ( & self , sess : & Session , scopes : RemapPathScopeComponents ) -> Self :: Output < ' _ > {
1536- if sess. opts . unstable_opts . remap_path_scope . contains ( scopes) {
1540+ fn for_scope ( & self , sess : & Session , scope : RemapPathScopeComponents ) -> Self :: Output < ' _ > {
1541+ assert ! (
1542+ scope. bits( ) . count_ones( ) == 1 ,
1543+ "one and only one scope should be passed to for_scope"
1544+ ) ;
1545+ if sess. opts . unstable_opts . remap_path_scope . contains ( scope) {
15371546 self . prefer_remapped_unconditionaly ( )
15381547 } else {
15391548 self . prefer_local ( )
@@ -1552,8 +1561,12 @@ impl RemapFileNameExt for rustc_span::FileName {
15521561impl RemapFileNameExt for rustc_span:: RealFileName {
15531562 type Output < ' a > = & ' a Path ;
15541563
1555- fn for_scope ( & self , sess : & Session , scopes : RemapPathScopeComponents ) -> Self :: Output < ' _ > {
1556- if sess. opts . unstable_opts . remap_path_scope . contains ( scopes) {
1564+ fn for_scope ( & self , sess : & Session , scope : RemapPathScopeComponents ) -> Self :: Output < ' _ > {
1565+ assert ! (
1566+ scope. bits( ) . count_ones( ) == 1 ,
1567+ "one and only one scope should be passed to for_scope"
1568+ ) ;
1569+ if sess. opts . unstable_opts . remap_path_scope . contains ( scope) {
15571570 self . remapped_path_if_available ( )
15581571 } else {
15591572 self . local_path_if_available ( )
0 commit comments