@@ -42,7 +42,7 @@ use std::io;
42
42
use std:: iter:: TrustedLen ;
43
43
use std:: mem;
44
44
use std:: num:: NonZeroUsize ;
45
- use std:: path:: PathBuf ;
45
+ use std:: path:: Path ;
46
46
use tracing:: debug;
47
47
48
48
pub ( super ) use cstore_impl:: provide;
@@ -1473,34 +1473,28 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1473
1473
//
1474
1474
// NOTE: if you update this, you might need to also update bootstrap's code for generating
1475
1475
// 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
+ } ) ;
1496
1490
let try_to_translate_virtual_to_real = |name : & mut rustc_span:: FileName | {
1497
1491
debug ! (
1498
1492
"try_to_translate_virtual_to_real(name={:?}): \
1499
1493
virtual_rust_source_base_dir={:?}, real_rust_source_base_dir={:?}",
1500
1494
name, virtual_rust_source_base_dir, sess. opts. real_rust_source_base_dir,
1501
1495
) ;
1502
1496
1503
- for virtual_dir in & virtual_rust_source_base_dir {
1497
+ if let Some ( virtual_dir) = virtual_rust_source_base_dir {
1504
1498
if let Some ( real_dir) = & sess. opts . real_rust_source_base_dir {
1505
1499
if let rustc_span:: FileName :: Real ( old_name) = name {
1506
1500
if let rustc_span:: RealFileName :: Remapped { local_path : _, virtual_name } =
0 commit comments