Skip to content

Commit

Permalink
Mark @RUSTC_BUILTIN search path usage as unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
Veykril committed Apr 23, 2024
1 parent a77f76e commit c174b96
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ fn test_search_paths_tracking_hash_different_order() {
&opts.target_triple,
&early_dcx,
search_path,
false,
));
};

Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2548,7 +2548,13 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M

let mut search_paths = vec![];
for s in &matches.opt_strs("L") {
search_paths.push(SearchPath::from_cli_opt(&sysroot, &target_triple, early_dcx, s));
search_paths.push(SearchPath::from_cli_opt(
&sysroot,
&target_triple,
early_dcx,
s,
unstable_opts.unstable_options,
));
}

let working_dir = std::env::current_dir().unwrap_or_else(|e| {
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_session/src/search_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ impl SearchPath {
triple: &TargetTriple,
early_dcx: &EarlyDiagCtxt,
path: &str,
is_unstable_enabled: bool,
) -> Self {
let (kind, path) = if let Some(stripped) = path.strip_prefix("native=") {
(PathKind::Native, stripped)
Expand All @@ -68,6 +69,14 @@ impl SearchPath {
};
let dir = match path.strip_prefix("@RUSTC_BUILTIN") {
Some(stripped) => {
if !is_unstable_enabled {
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
early_dcx.early_fatal(
"the `-Z unstable-options` flag must also be passed to \
enable the use of `@RUSTC_BUILTIN`",
);
}

make_target_lib_path(sysroot, triple.triple()).join("builtin").join(stripped)
}
None => PathBuf::from(path),
Expand Down
10 changes: 9 additions & 1 deletion src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,15 @@ impl Options {
let libs = matches
.opt_strs("L")
.iter()
.map(|s| SearchPath::from_cli_opt(&sysroot, &target, early_dcx, s))
.map(|s| {
SearchPath::from_cli_opt(
&sysroot,
&target,
early_dcx,
s,
unstable_opts.unstable_options,
)
})
.collect();

let show_coverage = matches.opt_present("show-coverage");
Expand Down

0 comments on commit c174b96

Please sign in to comment.