about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-06-12 03:14:53 +0200
committerGitHub <noreply@github.com>2025-06-12 03:14:53 +0200
commit78d83952e4ed6aa0a450aa58780d807facf2218e (patch)
tree4b3e2767a28ef8d065dfc24e2536d12dc8e36bf4
parentbb9dda1272d30ec6a3fbc04ab6abbb8f57fa6eab (diff)
parent208f2e461c19ca62bc43e8797728bbc7308b05ba (diff)
downloadrust-78d83952e4ed6aa0a450aa58780d807facf2218e.tar.gz
rust-78d83952e4ed6aa0a450aa58780d807facf2218e.zip
Rollup merge of #142318 - Urgau:cleanup-rust-src-remap, r=jieyouxu
Cleanup `rust-src` remapping and real dir

When remapping, `bootstrap` sets `CFG_VIRTUAL_RUST_SOURCE_BASE_DIR` to indicate what the base build dir (`/` of this repo) was remapped to, ie. `/rustc/...`.

It is therefore impossible when stripping `/rustc/...` from a remapped path to be inside the our `library/` directory, nevertheless we have code that assumed it was possible and helpfully tried to correct it. I don't why this was done, but it's not necessary.

~~The normalization in compiletest of `$SRC_DIR_REAL` was also slightly wrong, it ate the `library` part for no reason.~~ EDIT: there is a reason, it affects too much tests otherwise

r? `@jieyouxu`
-rw-r--r--compiler/rustc_metadata/src/rmeta/decoder.rs29
1 files changed, 1 insertions, 28 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs
index 1dae858b7ef..1953eef8170 100644
--- a/compiler/rustc_metadata/src/rmeta/decoder.rs
+++ b/compiler/rustc_metadata/src/rmeta/decoder.rs
@@ -1649,34 +1649,7 @@ impl<'a> CrateMetadataRef<'a> {
                         old_name
                     && let Ok(rest) = virtual_name.strip_prefix(virtual_dir)
                 {
-                    // The std library crates are in
-                    // `$sysroot/lib/rustlib/src/rust/library`, whereas other crates
-                    // may be in `$sysroot/lib/rustlib/src/rust/` directly. So we
-                    // detect crates from the std libs and handle them specially.
-                    const STD_LIBS: &[&str] = &[
-                        "core",
-                        "alloc",
-                        "std",
-                        "test",
-                        "term",
-                        "unwind",
-                        "proc_macro",
-                        "panic_abort",
-                        "panic_unwind",
-                        "profiler_builtins",
-                        "rtstartup",
-                        "rustc-std-workspace-core",
-                        "rustc-std-workspace-alloc",
-                        "rustc-std-workspace-std",
-                        "backtrace",
-                    ];
-                    let is_std_lib = STD_LIBS.iter().any(|l| rest.starts_with(l));
-
-                    let new_path = if is_std_lib {
-                        real_dir.join("library").join(rest)
-                    } else {
-                        real_dir.join(rest)
-                    };
+                    let new_path = real_dir.join(rest);
 
                     debug!(
                         "try_to_translate_virtual_to_real: `{}` -> `{}`",