@@ -41,7 +41,7 @@ use std::io;
41
41
use std:: iter:: TrustedLen ;
42
42
use std:: mem;
43
43
use std:: num:: NonZeroUsize ;
44
- use std:: path:: Path ;
44
+ use std:: path:: PathBuf ;
45
45
use tracing:: debug;
46
46
47
47
pub ( super ) use cstore_impl:: provide;
@@ -1472,28 +1472,34 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1472
1472
//
1473
1473
// NOTE: if you update this, you might need to also update bootstrap's code for generating
1474
1474
// the `rust-src` component in `Src::run` in `src/bootstrap/dist.rs`.
1475
- let virtual_rust_source_base_dir = option_env ! ( "CFG_VIRTUAL_RUST_SOURCE_BASE_DIR" )
1476
- . map ( Path :: new)
1477
- . filter ( |_| {
1478
- // Only spend time on further checks if we have what to translate *to*.
1479
- sess. opts . real_rust_source_base_dir . is_some ( )
1480
- // Some tests need the translation to be always skipped.
1481
- && sess. opts . debugging_opts . translate_remapped_path_to_local_path
1482
- } )
1483
- . filter ( |virtual_dir| {
1484
- // Don't translate away `/rustc/$hash` if we're still remapping to it,
1485
- // since that means we're still building `std`/`rustc` that need it,
1486
- // and we don't want the real path to leak into codegen/debuginfo.
1487
- !sess. opts . remap_path_prefix . iter ( ) . any ( |( _from, to) | to == virtual_dir)
1488
- } ) ;
1475
+ let virtual_rust_source_base_dir = [
1476
+ option_env ! ( "CFG_VIRTUAL_RUST_SOURCE_BASE_DIR" ) . map ( PathBuf :: from) ,
1477
+ sess. opts . debugging_opts . simulate_remapped_rust_src_base . clone ( ) ,
1478
+ ]
1479
+ . into_iter ( )
1480
+ . filter ( |_| {
1481
+ // Only spend time on further checks if we have what to translate *to*.
1482
+ sess. opts . real_rust_source_base_dir . is_some ( )
1483
+ // Some tests need the translation to be always skipped.
1484
+ && sess. opts . debugging_opts . translate_remapped_path_to_local_path
1485
+ } )
1486
+ . flatten ( )
1487
+ . filter ( |virtual_dir| {
1488
+ // Don't translate away `/rustc/$hash` if we're still remapping to it,
1489
+ // since that means we're still building `std`/`rustc` that need it,
1490
+ // and we don't want the real path to leak into codegen/debuginfo.
1491
+ !sess. opts . remap_path_prefix . iter ( ) . any ( |( _from, to) | to == virtual_dir)
1492
+ } )
1493
+ . collect :: < Vec < _ > > ( ) ;
1494
+
1489
1495
let try_to_translate_virtual_to_real = |name : & mut rustc_span:: FileName | {
1490
1496
debug ! (
1491
1497
"try_to_translate_virtual_to_real(name={:?}): \
1492
1498
virtual_rust_source_base_dir={:?}, real_rust_source_base_dir={:?}",
1493
1499
name, virtual_rust_source_base_dir, sess. opts. real_rust_source_base_dir,
1494
1500
) ;
1495
1501
1496
- if let Some ( virtual_dir) = virtual_rust_source_base_dir {
1502
+ for virtual_dir in & virtual_rust_source_base_dir {
1497
1503
if let Some ( real_dir) = & sess. opts . real_rust_source_base_dir {
1498
1504
if let rustc_span:: FileName :: Real ( old_name) = name {
1499
1505
if let rustc_span:: RealFileName :: Remapped { local_path : _, virtual_name } =
0 commit comments