From a59589b1cc7799ac847763ef0395f4d48aabf883 Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 23 May 2024 15:30:46 +0200 Subject: [PATCH] Replace fake "restricted-std" Cargo feature by custom cfg --- library/std/build.rs | 3 ++- library/std/src/lib.rs | 4 ++-- src/bootstrap/src/lib.rs | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/library/std/build.rs b/library/std/build.rs index 7a47b52e8e4..04f6f666875 100644 --- a/library/std/build.rs +++ b/library/std/build.rs @@ -10,6 +10,7 @@ fn main() { if target_os == "netbsd" && env::var("RUSTC_STD_NETBSD10").is_ok() { println!("cargo:rustc-cfg=netbsd10"); } + println!("cargo:rustc-check-cfg=cfg(restricted_std)"); if target_os == "linux" || target_os == "android" || target_os == "netbsd" @@ -59,7 +60,7 @@ fn main() { // - arch=avr // - JSON targets // - Any new targets that have not been explicitly added above. - println!("cargo:rustc-cfg=feature=\"restricted-std\""); + println!("cargo:rustc-cfg=restricted_std"); } println!("cargo:rustc-env=STD_ENV_ARCH={}", env::var("CARGO_CFG_TARGET_ARCH").unwrap()); println!("cargo:rustc-cfg=backtrace_in_libstd"); diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 949c543a264..4a18db3d5a3 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -213,9 +213,9 @@ //! [array]: prim@array //! [slice]: prim@slice -#![cfg_attr(not(feature = "restricted-std"), stable(feature = "rust1", since = "1.0.0"))] +#![cfg_attr(not(restricted_std), stable(feature = "rust1", since = "1.0.0"))] #![cfg_attr( - feature = "restricted-std", + restricted_std, unstable( feature = "restricted_std", issue = "none", diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 38de5e38000..af9fc32c98c 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -94,6 +94,7 @@ (Some(Mode::Std), "no_sync", None), (Some(Mode::Std), "netbsd10", None), (Some(Mode::Std), "backtrace_in_libstd", None), + (Some(Mode::Std), "restricted_std", None), /* Extra values not defined in the built-in targets yet, but used in std */ (Some(Mode::Std), "target_env", Some(&["libnx", "p2"])), (Some(Mode::Std), "target_os", Some(&["visionos"])),