@@ -193,22 +193,22 @@ pub use scoped::{scope, Scope, ScopedJoinHandle};
193193#[ macro_use]
194194mod local;
195195
196- # [ stable ( feature = "rust1" , since = "1.0.0" ) ]
197- pub use self :: local :: { AccessError , LocalKey } ;
198-
199- // Provide the type used by the thread_local! macro to access TLS keys. This
200- // needs to be kept in sync with the macro itself (in `local.rs`).
201- // There are three types: "static", "fast", "OS". The "OS" thread local key
202- // type is accessed via platform-specific API calls and is slow, while the "fast"
203- // key type is accessed via code generated via LLVM, where TLS keys are set up
204- // by the elf linker. "static" is for single-threaded platforms where a global
205- // static is sufficient .
206-
207- // Implementation details used by the thread_local!{} macro.
208- # [ doc ( hidden ) ]
209- # [ unstable ( feature = "thread_local_internals" , issue = "none" ) ]
210- pub mod local_impl {
211- pub use crate :: sys :: common :: thread_local :: { thread_local_inner , Key } ;
196+ cfg_if :: cfg_if! {
197+ if # [ cfg ( test ) ] {
198+ // Avoid duplicating the global state assoicated with thread-locals between this crate and
199+ // realstd. Miri relies on this.
200+ pub use realstd :: thread :: { local_impl , AccessError , LocalKey } ;
201+ } else {
202+ # [ stable ( feature = "rust1" , since = "1.0.0" ) ]
203+ pub use self :: local :: { AccessError , LocalKey } ;
204+
205+ // Implementation details used by the thread_local!{} macro .
206+ # [ doc ( hidden ) ]
207+ # [ unstable ( feature = "thread_local_internals" , issue = "none" ) ]
208+ pub mod local_impl {
209+ pub use crate :: sys :: common :: thread_local :: { thread_local_inner , Key } ;
210+ }
211+ }
212212}
213213
214214////////////////////////////////////////////////////////////////////////////////
0 commit comments