@@ -1524,16 +1524,25 @@ pub trait RemapFileNameExt {
1524
1524
where
1525
1525
Self : ' a ;
1526
1526
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 < ' _ > ;
1528
1532
1533
+ /// Return a possibly remapped filename, to be used in "codegen" related parts.
1529
1534
fn for_codegen ( & self , sess : & Session ) -> Self :: Output < ' _ > ;
1530
1535
}
1531
1536
1532
1537
impl RemapFileNameExt for rustc_span:: FileName {
1533
1538
type Output < ' a > = rustc_span:: FileNameDisplay < ' a > ;
1534
1539
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) {
1537
1546
self . prefer_remapped_unconditionaly ( )
1538
1547
} else {
1539
1548
self . prefer_local ( )
@@ -1552,8 +1561,12 @@ impl RemapFileNameExt for rustc_span::FileName {
1552
1561
impl RemapFileNameExt for rustc_span:: RealFileName {
1553
1562
type Output < ' a > = & ' a Path ;
1554
1563
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) {
1557
1570
self . remapped_path_if_available ( )
1558
1571
} else {
1559
1572
self . local_path_if_available ( )
0 commit comments