@@ -41,7 +41,7 @@ use std::io;
4141use std:: iter:: TrustedLen ;
4242use std:: mem;
4343use std:: num:: NonZeroUsize ;
44- use std:: path:: Path ;
44+ use std:: path:: PathBuf ;
4545use tracing:: debug;
4646
4747pub ( super ) use cstore_impl:: provide;
@@ -1472,28 +1472,34 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
14721472 //
14731473 // NOTE: if you update this, you might need to also update bootstrap's code for generating
14741474 // 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+
14891495 let try_to_translate_virtual_to_real = |name : & mut rustc_span:: FileName | {
14901496 debug ! (
14911497 "try_to_translate_virtual_to_real(name={:?}): \
14921498 virtual_rust_source_base_dir={:?}, real_rust_source_base_dir={:?}",
14931499 name, virtual_rust_source_base_dir, sess. opts. real_rust_source_base_dir,
14941500 ) ;
14951501
1496- if let Some ( virtual_dir) = virtual_rust_source_base_dir {
1502+ for virtual_dir in & virtual_rust_source_base_dir {
14971503 if let Some ( real_dir) = & sess. opts . real_rust_source_base_dir {
14981504 if let rustc_span:: FileName :: Real ( old_name) = name {
14991505 if let rustc_span:: RealFileName :: Remapped { local_path : _, virtual_name } =
0 commit comments