Inline the is_tool check for setting -Zforce-unstable-if-unmarked

This commit is contained in:
Zalathar 2026-02-15 21:16:35 +11:00
parent 139651428d
commit f1664acfbf
2 changed files with 12 additions and 9 deletions

View file

@ -999,8 +999,18 @@ impl Builder<'_> {
cargo.env("UPDATE_EXPECT", "1");
}
if !mode.is_tool() {
cargo.env("RUSTC_FORCE_UNSTABLE", "1");
// Set an environment variable that tells the rustc/rustdoc wrapper
// binary to pass `-Zforce-unstable-if-unmarked` to the real compiler.
match mode {
// Any library crate that's part of the sysroot should be marked unstable
// (including third-party dependencies), unless it uses a staged_api
// `#![stable(..)]` attribute to explicitly mark itself stable.
Mode::Std | Mode::Codegen | Mode::Rustc => {
cargo.env("RUSTC_FORCE_UNSTABLE", "1");
}
// For everything else, crate stability shouldn't matter, so don't set a flag.
Mode::ToolBootstrap | Mode::ToolRustcPrivate | Mode::ToolStd | Mode::ToolTarget => {}
}
if let Some(x) = self.crt_static(target) {

View file

@ -340,13 +340,6 @@ pub enum Mode {
}
impl Mode {
pub fn is_tool(&self) -> bool {
match self {
Mode::ToolBootstrap | Mode::ToolRustcPrivate | Mode::ToolStd | Mode::ToolTarget => true,
Mode::Std | Mode::Codegen | Mode::Rustc => false,
}
}
pub fn must_support_dlopen(&self) -> bool {
match self {
Mode::Std | Mode::Codegen => true,