Rollup merge of #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 #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
This commit is contained in:
commit
23012b5200
10 changed files with 1 additions and 34 deletions
|
@ -51,7 +51,6 @@
|
||||||
#![feature(control_flow_enum)]
|
#![feature(control_flow_enum)]
|
||||||
#![feature(associated_type_defaults)]
|
#![feature(associated_type_defaults)]
|
||||||
#![feature(iter_zip)]
|
#![feature(iter_zip)]
|
||||||
#![feature(thread_local_const_init)]
|
|
||||||
#![feature(trusted_step)]
|
#![feature(trusted_step)]
|
||||||
#![feature(try_blocks)]
|
#![feature(try_blocks)]
|
||||||
#![feature(try_reserve_kind)]
|
#![feature(try_reserve_kind)]
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#![feature(iter_zip)]
|
#![feature(iter_zip)]
|
||||||
#![feature(let_else)]
|
#![feature(let_else)]
|
||||||
#![feature(min_specialization)]
|
#![feature(min_specialization)]
|
||||||
#![feature(thread_local_const_init)]
|
|
||||||
#![feature(extern_types)]
|
#![feature(extern_types)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#![feature(negative_impls)]
|
#![feature(negative_impls)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
#![feature(min_specialization)]
|
#![feature(min_specialization)]
|
||||||
#![feature(thread_local_const_init)]
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rustc_macros;
|
extern crate rustc_macros;
|
||||||
|
|
|
@ -216,10 +216,7 @@
|
||||||
// std may use features in a platform-specific way
|
// std may use features in a platform-specific way
|
||||||
#![allow(unused_features)]
|
#![allow(unused_features)]
|
||||||
#![feature(rustc_allow_const_fn_unstable)]
|
#![feature(rustc_allow_const_fn_unstable)]
|
||||||
#![cfg_attr(
|
#![cfg_attr(test, feature(internal_output_capture, print_internals, update_panic_count))]
|
||||||
test,
|
|
||||||
feature(internal_output_capture, print_internals, update_panic_count, thread_local_const_init)
|
|
||||||
)]
|
|
||||||
#![cfg_attr(
|
#![cfg_attr(
|
||||||
all(target_vendor = "fortanix", target_env = "sgx"),
|
all(target_vendor = "fortanix", target_env = "sgx"),
|
||||||
feature(slice_index_methods, coerce_unsized, sgx_platform)
|
feature(slice_index_methods, coerce_unsized, sgx_platform)
|
||||||
|
|
|
@ -178,7 +178,6 @@ macro_rules! __thread_local_inner {
|
||||||
(@key $t:ty, const $init:expr) => {{
|
(@key $t:ty, const $init:expr) => {{
|
||||||
#[cfg_attr(not(windows), inline)] // see comments below
|
#[cfg_attr(not(windows), inline)] // see comments below
|
||||||
unsafe fn __getit() -> $crate::option::Option<&'static $t> {
|
unsafe fn __getit() -> $crate::option::Option<&'static $t> {
|
||||||
const _REQUIRE_UNSTABLE: () = $crate::thread::require_unstable_const_init_thread_local();
|
|
||||||
const INIT_EXPR: $t = $init;
|
const INIT_EXPR: $t = $init;
|
||||||
|
|
||||||
// wasm without atomics maps directly to `static mut`, and dtors
|
// wasm without atomics maps directly to `static mut`, and dtors
|
||||||
|
|
|
@ -204,13 +204,6 @@ pub use self::local::os::Key as __OsLocalKeyInner;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use self::local::statik::Key as __StaticLocalKeyInner;
|
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
|
// Builder
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
#![feature(thread_local_const_init)]
|
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
// ignore-android does not use #[thread_local]
|
// ignore-android does not use #[thread_local]
|
||||||
|
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
#![feature(thread_local_const_init)]
|
|
||||||
|
|
||||||
extern crate thread_local_aux as aux;
|
extern crate thread_local_aux as aux;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
thread_local!(static X: u32 = const { 0 });
|
|
||||||
//~^ ERROR: use of unstable library feature 'thread_local_const_init'
|
|
||||||
|
|
||||||
fn main() {}
|
|
|
@ -1,13 +0,0 @@
|
||||||
error[E0658]: use of unstable library feature 'thread_local_const_init'
|
|
||||||
--> $DIR/thread-local-const-init.rs:1:1
|
|
||||||
|
|
|
||||||
LL | thread_local!(static X: u32 = const { 0 });
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: see issue #84223 <https://github.com/rust-lang/rust/issues/84223> for more information
|
|
||||||
= help: add `#![feature(thread_local_const_init)]` to the crate attributes to enable
|
|
||||||
= note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0658`.
|
|
Loading…
Add table
Add a link
Reference in a new issue