From f1664acfbfe7335bfb59cdebf940342a6157ea9d Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sun, 15 Feb 2026 21:16:35 +1100 Subject: [PATCH] Inline the `is_tool` check for setting `-Zforce-unstable-if-unmarked` --- src/bootstrap/src/core/builder/cargo.rs | 14 ++++++++++++-- src/bootstrap/src/lib.rs | 7 ------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index e3fa826c45af3..7f4e23881e455 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -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) { diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index dfa29b5aa3cd3..ec5c6fbe1d01d 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -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,