@@ -1510,16 +1510,25 @@ pub trait RemapFileNameExt {
1510
1510
where
1511
1511
Self : ' a ;
1512
1512
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 < ' _ > ;
1514
1518
1519
+ /// Return a possibly remapped filename, to be used in "codegen" related parts.
1515
1520
fn for_codegen ( & self , sess : & Session ) -> Self :: Output < ' _ > ;
1516
1521
}
1517
1522
1518
1523
impl RemapFileNameExt for rustc_span:: FileName {
1519
1524
type Output < ' a > = rustc_span:: FileNameDisplay < ' a > ;
1520
1525
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) {
1523
1532
self . prefer_remapped_unconditionaly ( )
1524
1533
} else {
1525
1534
self . prefer_local ( )
@@ -1538,8 +1547,12 @@ impl RemapFileNameExt for rustc_span::FileName {
1538
1547
impl RemapFileNameExt for rustc_span:: RealFileName {
1539
1548
type Output < ' a > = & ' a Path ;
1540
1549
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) {
1543
1556
self . remapped_path_if_available ( )
1544
1557
} else {
1545
1558
self . local_path_if_available ( )
0 commit comments