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