@@ -1510,16 +1510,25 @@ pub trait RemapFileNameExt {
15101510 where
15111511 Self : ' a ;
15121512
1513- fn for_scope ( & self , sess : & Session , scopes : RemapPathScopeComponents ) -> Self :: Output < ' _ > ;
1513+ /// Returns a possibly remapped filename based on the passed scope and remap cli options.
1514+ ///
1515+ /// One and only one scope should be passed to this method. For anything related to
1516+ /// "codegen" see the [`RemapFileNameExt::for_codegen`] method.
1517+ fn for_scope ( & self , sess : & Session , scope : RemapPathScopeComponents ) -> Self :: Output < ' _ > ;
15141518
1519+ /// Return a possibly remapped filename, to be used in "codegen" related parts.
15151520 fn for_codegen ( & self , sess : & Session ) -> Self :: Output < ' _ > ;
15161521}
15171522
15181523impl RemapFileNameExt for rustc_span:: FileName {
15191524 type Output < ' a > = rustc_span:: FileNameDisplay < ' a > ;
15201525
1521- fn for_scope ( & self , sess : & Session , scopes : RemapPathScopeComponents ) -> Self :: Output < ' _ > {
1522- if sess. opts . unstable_opts . remap_path_scope . contains ( scopes) {
1526+ fn for_scope ( & self , sess : & Session , scope : RemapPathScopeComponents ) -> Self :: Output < ' _ > {
1527+ assert ! (
1528+ scope. bits( ) . count_ones( ) == 1 ,
1529+ "one and only one scope should be passed to for_scope"
1530+ ) ;
1531+ if sess. opts . unstable_opts . remap_path_scope . contains ( scope) {
15231532 self . prefer_remapped_unconditionaly ( )
15241533 } else {
15251534 self . prefer_local ( )
@@ -1538,8 +1547,12 @@ impl RemapFileNameExt for rustc_span::FileName {
15381547impl RemapFileNameExt for rustc_span:: RealFileName {
15391548 type Output < ' a > = & ' a Path ;
15401549
1541- fn for_scope ( & self , sess : & Session , scopes : RemapPathScopeComponents ) -> Self :: Output < ' _ > {
1542- if sess. opts . unstable_opts . remap_path_scope . contains ( scopes) {
1550+ fn for_scope ( & self , sess : & Session , scope : RemapPathScopeComponents ) -> Self :: Output < ' _ > {
1551+ assert ! (
1552+ scope. bits( ) . count_ones( ) == 1 ,
1553+ "one and only one scope should be passed to for_scope"
1554+ ) ;
1555+ if sess. opts . unstable_opts . remap_path_scope . contains ( scope) {
15431556 self . remapped_path_if_available ( )
15441557 } else {
15451558 self . local_path_if_available ( )
0 commit comments