From a0c959750abec28bb875be492c5f0532920a8907 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 29 Nov 2021 07:21:35 -0800 Subject: std: Stabilize the `thread_local_const_init` feature This commit is intended to follow the stabilization disposition of the FCP that has now finished in #84223. This stabilizes the ability to flag thread local initializers as `const` expressions which enables the macro to generate more efficient code for accessing it, notably removing runtime checks for initialization. More information can also be found in #84223 as well as the tests where the feature usage was removed in this PR. Closes #84223 --- library/std/src/lib.rs | 5 +---- library/std/src/thread/local.rs | 1 - library/std/src/thread/mod.rs | 7 ------- 3 files changed, 1 insertion(+), 12 deletions(-) (limited to 'library/std/src') diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 504c3b7e9f9..380de97407d 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -216,10 +216,7 @@ // std may use features in a platform-specific way #![allow(unused_features)] #![feature(rustc_allow_const_fn_unstable)] -#![cfg_attr( - test, - feature(internal_output_capture, print_internals, update_panic_count, thread_local_const_init) -)] +#![cfg_attr(test, feature(internal_output_capture, print_internals, update_panic_count))] #![cfg_attr( all(target_vendor = "fortanix", target_env = "sgx"), feature(slice_index_methods, coerce_unsized, sgx_platform) diff --git a/library/std/src/thread/local.rs b/library/std/src/thread/local.rs index 4da59577d78..ed0c47bc18f 100644 --- a/library/std/src/thread/local.rs +++ b/library/std/src/thread/local.rs @@ -164,7 +164,6 @@ macro_rules! __thread_local_inner { (@key $t:ty, const $init:expr) => {{ #[cfg_attr(not(windows), inline)] // see comments below unsafe fn __getit() -> $crate::option::Option<&'static $t> { - const _REQUIRE_UNSTABLE: () = $crate::thread::require_unstable_const_init_thread_local(); const INIT_EXPR: $t = $init; // wasm without atomics maps directly to `static mut`, and dtors diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 343d3ef8dc5..64f6c7fa022 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -204,13 +204,6 @@ pub use self::local::os::Key as __OsLocalKeyInner; #[doc(hidden)] pub use self::local::statik::Key as __StaticLocalKeyInner; -// This is only used to make thread locals with `const { .. }` initialization -// expressions unstable. If and/or when that syntax is stabilized with thread -// locals this will simply be removed. -#[doc(hidden)] -#[unstable(feature = "thread_local_const_init", issue = "84223")] -pub const fn require_unstable_const_init_thread_local() {} - //////////////////////////////////////////////////////////////////////////////// // Builder //////////////////////////////////////////////////////////////////////////////// -- cgit 1.4.1-3-g733a5