diff options
| author | bors <bors@rust-lang.org> | 2023-05-05 04:48:50 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-05-05 04:48:50 +0000 |
| commit | 3320f2fab64f36dae94b830f8c4b166857b6919b (patch) | |
| tree | ed35a767748983cfed5de4965d86393c393a9656 /library/std/src | |
| parent | 74c4821045c68d42bb8b8a7c998bdb5c2a72bd0d (diff) | |
| parent | 650dc01a644c0429cd4853749f9077ce353b29e6 (diff) | |
| download | rust-3320f2fab64f36dae94b830f8c4b166857b6919b.tar.gz rust-3320f2fab64f36dae94b830f8c4b166857b6919b.zip | |
Auto merge of #111231 - JohnTitor:rollup-a25ff8v, r=JohnTitor
Rollup of 8 pull requests Successful merges: - #110946 (avoid duplicating TLS state between test std and realstd) - #110954 (Reject borrows of projections in ConstProp.) - #111052 (Fix problems with backtraces in two ui tests.) - #111132 (cleanup nll generalizer) - #111173 (Still more encoder cleanups) - #111187 (bootstrap: add llvm-project/runtimes to the sources) - #111213 (Fixup "since" dates for `array_tuple_conv` feature) - #111223 (Use `free-args` consistently in bootstrap) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/sys/common/thread_local/mod.rs | 5 | ||||
| -rw-r--r-- | library/std/src/sys/common/thread_local/os_local.rs | 2 | ||||
| -rw-r--r-- | library/std/src/thread/mod.rs | 32 |
3 files changed, 22 insertions, 17 deletions
diff --git a/library/std/src/sys/common/thread_local/mod.rs b/library/std/src/sys/common/thread_local/mod.rs index 951d509ec95..77f64588310 100644 --- a/library/std/src/sys/common/thread_local/mod.rs +++ b/library/std/src/sys/common/thread_local/mod.rs @@ -1,5 +1,10 @@ #![unstable(feature = "thread_local_internals", reason = "should not be necessary", issue = "none")] +// There are three thread-local implementations: "static", "fast", "OS". +// The "OS" thread local key type is accessed via platform-specific API calls and is slow, while the +// "fast" key type is accessed via code generated via LLVM, where TLS keys are set up by the linker. +// "static" is for single-threaded platforms where a global static is sufficient. + cfg_if::cfg_if! { if #[cfg(all(target_family = "wasm", not(target_feature = "atomics")))] { #[doc(hidden)] diff --git a/library/std/src/sys/common/thread_local/os_local.rs b/library/std/src/sys/common/thread_local/os_local.rs index d004897df28..5d48ce1e03b 100644 --- a/library/std/src/sys/common/thread_local/os_local.rs +++ b/library/std/src/sys/common/thread_local/os_local.rs @@ -18,7 +18,7 @@ pub macro thread_local_inner { ) -> $crate::option::Option<&'static $t> { const INIT_EXPR: $t = $init; - // On platforms without `#[thread_local]` we fall back to the + // On platforms without `#[thread_local]` we fall back to the // same implementation as below for os thread locals. #[inline] const fn __init() -> $t { INIT_EXPR } diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 9cdc17a287c..f712c872708 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -193,22 +193,22 @@ pub use scoped::{scope, Scope, ScopedJoinHandle}; #[macro_use] mod local; -#[stable(feature = "rust1", since = "1.0.0")] -pub use self::local::{AccessError, LocalKey}; - -// Provide the type used by the thread_local! macro to access TLS keys. This -// needs to be kept in sync with the macro itself (in `local.rs`). -// There are three types: "static", "fast", "OS". The "OS" thread local key -// type is accessed via platform-specific API calls and is slow, while the "fast" -// key type is accessed via code generated via LLVM, where TLS keys are set up -// by the elf linker. "static" is for single-threaded platforms where a global -// static is sufficient. - -// Implementation details used by the thread_local!{} macro. -#[doc(hidden)] -#[unstable(feature = "thread_local_internals", issue = "none")] -pub mod local_impl { - pub use crate::sys::common::thread_local::{thread_local_inner, Key}; +cfg_if::cfg_if! { + if #[cfg(test)] { + // Avoid duplicating the global state assoicated with thread-locals between this crate and + // realstd. Miri relies on this. + pub use realstd::thread::{local_impl, AccessError, LocalKey}; + } else { + #[stable(feature = "rust1", since = "1.0.0")] + pub use self::local::{AccessError, LocalKey}; + + // Implementation details used by the thread_local!{} macro. + #[doc(hidden)] + #[unstable(feature = "thread_local_internals", issue = "none")] + pub mod local_impl { + pub use crate::sys::common::thread_local::{thread_local_inner, Key}; + } + } } //////////////////////////////////////////////////////////////////////////////// |
