@@ -1523,16 +1523,25 @@ pub trait RemapFileNameExt {
1523
1523
where
1524
1524
Self : ' a ;
1525
1525
1526
- fn for_scope ( & self , sess : & Session , scopes : RemapPathScopeComponents ) -> Self :: Output < ' _ > ;
1526
+ /// Returns a possibly remapped filename based on the passed scope and remap cli options.
1527
+ ///
1528
+ /// One and only one scope should be passed to this method. For anything related to
1529
+ /// "codegen" see the [`RemapFileNameExt::for_codegen`] method.
1530
+ fn for_scope ( & self , sess : & Session , scope : RemapPathScopeComponents ) -> Self :: Output < ' _ > ;
1527
1531
1532
+ /// Return a possibly remapped filename, to be used in "codegen" related parts.
1528
1533
fn for_codegen ( & self , sess : & Session ) -> Self :: Output < ' _ > ;
1529
1534
}
1530
1535
1531
1536
impl RemapFileNameExt for rustc_span:: FileName {
1532
1537
type Output < ' a > = rustc_span:: FileNameDisplay < ' a > ;
1533
1538
1534
- fn for_scope ( & self , sess : & Session , scopes : RemapPathScopeComponents ) -> Self :: Output < ' _ > {
1535
- if sess. opts . unstable_opts . remap_path_scope . contains ( scopes) {
1539
+ fn for_scope ( & self , sess : & Session , scope : RemapPathScopeComponents ) -> Self :: Output < ' _ > {
1540
+ assert ! (
1541
+ scope. bits( ) . count_ones( ) == 1 ,
1542
+ "one and only one scope should be passed to for_scope"
1543
+ ) ;
1544
+ if sess. opts . unstable_opts . remap_path_scope . contains ( scope) {
1536
1545
self . prefer_remapped_unconditionaly ( )
1537
1546
} else {
1538
1547
self . prefer_local ( )
@@ -1551,8 +1560,12 @@ impl RemapFileNameExt for rustc_span::FileName {
1551
1560
impl RemapFileNameExt for rustc_span:: RealFileName {
1552
1561
type Output < ' a > = & ' a Path ;
1553
1562
1554
- fn for_scope ( & self , sess : & Session , scopes : RemapPathScopeComponents ) -> Self :: Output < ' _ > {
1555
- if sess. opts . unstable_opts . remap_path_scope . contains ( scopes) {
1563
+ fn for_scope ( & self , sess : & Session , scope : RemapPathScopeComponents ) -> Self :: Output < ' _ > {
1564
+ assert ! (
1565
+ scope. bits( ) . count_ones( ) == 1 ,
1566
+ "one and only one scope should be passed to for_scope"
1567
+ ) ;
1568
+ if sess. opts . unstable_opts . remap_path_scope . contains ( scope) {
1556
1569
self . remapped_path_if_available ( )
1557
1570
} else {
1558
1571
self . local_path_if_available ( )
0 commit comments