Change:
// // NOTE: if you update this, you might need to also update bootstrap's code for generating // the `rust-src` component in `Src::run` in `src/bootstrap/dist.rs`. <del> let virtual_rust_source_base_dir = option_env!("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR") .map(Path::new) .filter(|_| { // Only spend time on further checks if we have what to translate *to*. sess.opts.real_rust_source_base_dir.is_some() // Some tests need the translation to be always skipped. && sess.opts.debugging_opts.translate_remapped_path_to_local_path }) .filter(|virtual_dir| { // Don't translate away `/rustc/$hash` if we're still remapping to it, // since that means we're still building `std`/`rustc` that need it, // and we don't want the real path to leak into codegen/debuginfo. !sess.opts.remap_path_prefix.iter().any(|(_from, to)| to == virtual_dir) }); </del> <ins> let virtual_rust_source_base_dir = [ option_env!("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR").map(PathBuf::from), sess.opts.debugging_opts.simulate_remapped_rust_src_base.clone(), ] .into_iter() .filter(|_| { // Only spend time on further checks if we have what to translate *to*. sess.opts.real_rust_source_base_dir.is_some() // Some tests need the translation to be always skipped. && sess.opts.debugging_opts.translate_remapped_path_to_local_path }) .flatten() .filter(|virtual_dir| { // Don't translate away `/rustc/$hash` if we're still remapping to it, // since that means we're still building `std`/`rustc` that need it, // and we don't want the real path to leak into codegen/debuginfo. !sess.opts.remap_path_prefix.iter().any(|(_from, to)| to == virtual_dir) }) .collect::<Vec<_>>(); </ins> let try_to_translate_virtual_to_real = |name: &mut rustc_span::FileName| { debug!( "try_to_translate_virtual_to_real(name={:?}): 

Discussion:
alternative title: is not working as expected with Hello! We are running the compiler test with a compiler configured with and after a recent PR merge we observed that the test suite is no longer passing. After looking into the issue I think a (test only?) compiler flag may not be working as intended. Details below and apologies for not using one of the issue templates! worked fine before PR with set in stopped working after was merged. more concretely, the UI test in PR fails. the error message looks like the one that was reported by CI in the original PR . see disabling makes test and the test suite pass: is not working as intended with . AIUI, the goal of is to make it as if there was no component installed but it's not working when the compiler is built with . This can be observed in the above test failure: the location of is reported. It can also be observed on nightly (shown below): only removing the component makes that note disappear. is not being exercised with in CI PR rebased PR but . with that change the test is run in the builder which is configured with the default of . (see ) I couldn't figure where in the source code is set for CI builders but for example is configured with (see ) but that builder does not run the tests. OTOH, is configured with (see ) and does run the tests. However, it will not run (see ) because the test has a directive. This builder is the one that failed in the original PR (again, see ); that original PR did not have the directive. is not working as intended with . of (1), is a hazard because it will fail if the configuration of the CI builders is tweaked in the future I would suggest: / disable the UI test -open issue and label it with . note that the actual issue is already fixed an issue about fixing (or re-purporse this issue for that) -add / re-enable test once (3) is sorted out cc (author of PR )
Thanks for reporting! Totally agree with your suggestions, I'm going to open a PR to disable that UI test later.
Opened , and retitled this issue as the issue is not limited to UI test, I think.
Found the cause of the mismatch between and !

When is passed to the compiler, when loading the standard library's / file paths are remapped on the fly, reproducing the same behavior of . This is correct. The problem is, below in the same file, another piece of code tries to determine the local path of a remapped path if available: That code is not correct, as it only looks at the prefix set by bootstrap when , not at the simulated prefix with the flag. This is the cause of the mismatch in behavior, and that code should be updated to also check for the simulated prefix (as the purpose of that flag is to fully simulate ). This also explains the difference identified depending on whether the component was installed: when it's not installed the second piece of code is skipped, as there is no local path to determine, causing the consistent behavior.
Opened to fix the test, and to fix the behavior of to be consistent.