Skip to content

Commit 23012b5

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 4af985a + a0c9597 commit 23012b5

File tree

10 files changed

+1
-34
lines changed

10 files changed

+1
-34
lines changed

compiler/rustc_middle/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
#![feature(control_flow_enum)]
5252
#![feature(associated_type_defaults)]
5353
#![feature(iter_zip)]
54-
#![feature(thread_local_const_init)]
5554
#![feature(trusted_step)]
5655
#![feature(try_blocks)]
5756
#![feature(try_reserve_kind)]

compiler/rustc_query_system/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#![feature(iter_zip)]
66
#![feature(let_else)]
77
#![feature(min_specialization)]
8-
#![feature(thread_local_const_init)]
98
#![feature(extern_types)]
109

1110
#[macro_use]

compiler/rustc_span/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#![feature(negative_impls)]
2121
#![feature(nll)]
2222
#![feature(min_specialization)]
23-
#![feature(thread_local_const_init)]
2423

2524
#[macro_use]
2625
extern crate rustc_macros;

library/std/src/lib.rs

+1-4
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)

library/std/src/thread/local.rs

-1
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

library/std/src/thread/mod.rs

-7
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
////////////////////////////////////////////////////////////////////////////////

src/test/codegen/auxiliary/thread_local_aux.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![crate_type = "lib"]
2-
#![feature(thread_local_const_init)]
32

43
use std::cell::Cell;
54

src/test/codegen/thread-local.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// ignore-android does not use #[thread_local]
77

88
#![crate_type = "lib"]
9-
#![feature(thread_local_const_init)]
109

1110
extern crate thread_local_aux as aux;
1211

src/test/ui/feature-gates/thread-local-const-init.rs

-4
This file was deleted.

src/test/ui/feature-gates/thread-local-const-init.stderr

-13
This file was deleted.

0 commit comments

Comments
 (0)