Skip to content

Commit 3d65c92

Browse files
committed
Replace implementation with @RUSTC_BUILTIN prefix substitution var
1 parent 2fae4ee commit 3d65c92

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

compiler/rustc_session/src/config.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2824,6 +2824,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
28242824
let logical_env = parse_logical_env(early_dcx, matches);
28252825

28262826
let sysroot = filesearch::materialize_sysroot(sysroot_opt);
2827+
28272828
let real_rust_source_base_dir = {
28282829
// This is the location used by the `rust-src` `rustup` component.
28292830
let mut candidate = sysroot.join("lib/rustlib/src/rust");

compiler/rustc_session/src/search_paths.rs

+7-14
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,20 @@ impl SearchPath {
6363
(PathKind::Framework, stripped)
6464
} else if let Some(stripped) = path.strip_prefix("all=") {
6565
(PathKind::All, stripped)
66-
} else if let Some(stripped) = path.strip_prefix("builtin:") {
67-
if stripped.contains(std::path::is_separator) {
68-
early_dcx.early_fatal("`-L builtin:` does not accept paths");
69-
}
70-
71-
let path =
72-
make_target_lib_path(sysroot, triple.triple()).join("builtin").join(stripped);
73-
if !path.is_dir() {
74-
early_dcx.early_fatal(format!("builtin:{stripped} does not exist"));
75-
}
76-
77-
return Self::new(PathKind::All, path);
7866
} else {
7967
(PathKind::All, path)
8068
};
81-
if path.is_empty() {
69+
let dir = match path.strip_prefix("@RUSTC_BUILTIN") {
70+
Some(stripped) => {
71+
make_target_lib_path(sysroot, triple.triple()).join("builtin").join(stripped)
72+
}
73+
None => PathBuf::from(path),
74+
};
75+
if dir.as_os_str().is_empty() {
8276
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
8377
early_dcx.early_fatal("empty search path given via `-L`");
8478
}
8579

86-
let dir = PathBuf::from(path);
8780
Self::new(kind, dir)
8881
}
8982

0 commit comments

Comments
 (0)