@@ -1605,56 +1605,49 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1605
1605
) ;
1606
1606
1607
1607
for virtual_dir in virtual_rust_source_base_dir. iter ( ) . flatten ( ) {
1608
- if let Some ( real_dir) = & sess. opts . real_rust_source_base_dir {
1609
- if let rustc_span:: FileName :: Real ( old_name) = name {
1610
- if let rustc_span:: RealFileName :: Remapped { local_path : _, virtual_name } =
1611
- old_name
1612
- {
1613
- if let Ok ( rest) = virtual_name. strip_prefix ( virtual_dir) {
1614
- let virtual_name = virtual_name. clone ( ) ;
1615
-
1616
- // The std library crates are in
1617
- // `$sysroot/lib/rustlib/src/rust/library`, whereas other crates
1618
- // may be in `$sysroot/lib/rustlib/src/rust/` directly. So we
1619
- // detect crates from the std libs and handle them specially.
1620
- const STD_LIBS : & [ & str ] = & [
1621
- "core" ,
1622
- "alloc" ,
1623
- "std" ,
1624
- "test" ,
1625
- "term" ,
1626
- "unwind" ,
1627
- "proc_macro" ,
1628
- "panic_abort" ,
1629
- "panic_unwind" ,
1630
- "profiler_builtins" ,
1631
- "rtstartup" ,
1632
- "rustc-std-workspace-core" ,
1633
- "rustc-std-workspace-alloc" ,
1634
- "rustc-std-workspace-std" ,
1635
- "backtrace" ,
1636
- ] ;
1637
- let is_std_lib = STD_LIBS . iter ( ) . any ( |l| rest. starts_with ( l) ) ;
1638
-
1639
- let new_path = if is_std_lib {
1640
- real_dir. join ( "library" ) . join ( rest)
1641
- } else {
1642
- real_dir. join ( rest)
1643
- } ;
1644
-
1645
- debug ! (
1646
- "try_to_translate_virtual_to_real: `{}` -> `{}`" ,
1647
- virtual_name. display( ) ,
1648
- new_path. display( ) ,
1649
- ) ;
1650
- let new_name = rustc_span:: RealFileName :: Remapped {
1651
- local_path : Some ( new_path) ,
1652
- virtual_name,
1653
- } ;
1654
- * old_name = new_name;
1655
- }
1656
- }
1657
- }
1608
+ if let Some ( real_dir) = & sess. opts . real_rust_source_base_dir
1609
+ && let rustc_span:: FileName :: Real ( old_name) = name
1610
+ && let rustc_span:: RealFileName :: Remapped { local_path : _, virtual_name } =
1611
+ old_name
1612
+ && let Ok ( rest) = virtual_name. strip_prefix ( virtual_dir) {
1613
+ let virtual_name = virtual_name. clone ( ) ;
1614
+
1615
+ // The std library crates are in
1616
+ // `$sysroot/lib/rustlib/src/rust/library`, whereas other crates
1617
+ // may be in `$sysroot/lib/rustlib/src/rust/` directly. So we
1618
+ // detect crates from the std libs and handle them specially.
1619
+ const STD_LIBS : & [ & str ] = & [
1620
+ "core" ,
1621
+ "alloc" ,
1622
+ "std" ,
1623
+ "test" ,
1624
+ "term" ,
1625
+ "unwind" ,
1626
+ "proc_macro" ,
1627
+ "panic_abort" ,
1628
+ "panic_unwind" ,
1629
+ "profiler_builtins" ,
1630
+ "rtstartup" ,
1631
+ "rustc-std-workspace-core" ,
1632
+ "rustc-std-workspace-alloc" ,
1633
+ "rustc-std-workspace-std" ,
1634
+ "backtrace" ,
1635
+ ] ;
1636
+ let is_std_lib = STD_LIBS . iter ( ) . any ( |l| rest. starts_with ( l) ) ;
1637
+
1638
+ let new_path = if is_std_lib {
1639
+ real_dir. join ( "library" ) . join ( rest)
1640
+ } else {
1641
+ real_dir. join ( rest)
1642
+ } ;
1643
+
1644
+ debug ! (
1645
+ "try_to_translate_virtual_to_real: `{}` -> `{}`" ,
1646
+ virtual_name. display( ) ,
1647
+ new_path. display( ) ,
1648
+ ) ;
1649
+ let new_name = rustc_span:: RealFileName :: LocalPath ( new_path) ;
1650
+ * old_name = new_name;
1658
1651
}
1659
1652
}
1660
1653
} ;
0 commit comments