Skip to content

Commit 6cdc31d

Browse files
authored
Rollup merge of rust-lang#91355 - alexcrichton:stabilize-thread-local-const, r=m-ou-se
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 rust-lang#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 rust-lang#84223 as well as the tests where the feature usage was removed in this PR. Closes rust-lang#84223
2 parents 975dffc + e2b0e74 commit 6cdc31d

File tree

3 files changed

+1
-12
lines changed

3 files changed

+1
-12
lines changed

std/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,7 @@
216216
// std may use features in a platform-specific way
217217
#![allow(unused_features)]
218218
#![feature(rustc_allow_const_fn_unstable)]
219-
#![cfg_attr(
220-
test,
221-
feature(internal_output_capture, print_internals, update_panic_count, thread_local_const_init)
222-
)]
219+
#![cfg_attr(test, feature(internal_output_capture, print_internals, update_panic_count))]
223220
#![cfg_attr(
224221
all(target_vendor = "fortanix", target_env = "sgx"),
225222
feature(slice_index_methods, coerce_unsized, sgx_platform)

std/src/thread/local.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ macro_rules! __thread_local_inner {
178178
(@key $t:ty, const $init:expr) => {{
179179
#[cfg_attr(not(windows), inline)] // see comments below
180180
unsafe fn __getit() -> $crate::option::Option<&'static $t> {
181-
const _REQUIRE_UNSTABLE: () = $crate::thread::require_unstable_const_init_thread_local();
182181
const INIT_EXPR: $t = $init;
183182

184183
// wasm without atomics maps directly to `static mut`, and dtors

std/src/thread/mod.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,6 @@ pub use self::local::os::Key as __OsLocalKeyInner;
204204
#[doc(hidden)]
205205
pub use self::local::statik::Key as __StaticLocalKeyInner;
206206

207-
// This is only used to make thread locals with `const { .. }` initialization
208-
// expressions unstable. If and/or when that syntax is stabilized with thread
209-
// locals this will simply be removed.
210-
#[doc(hidden)]
211-
#[unstable(feature = "thread_local_const_init", issue = "84223")]
212-
pub const fn require_unstable_const_init_thread_local() {}
213-
214207
////////////////////////////////////////////////////////////////////////////////
215208
// Builder
216209
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)