@@ -192,32 +192,49 @@ pub use scoped::{scope, Scope, ScopedJoinHandle};
192192#[ stable( feature = "rust1" , since = "1.0.0" ) ]
193193pub use self :: local:: { AccessError , LocalKey } ;
194194
195- // Select the type used by the thread_local! macro to access TLS keys. There
196- // are three types: "static", "fast", "OS". The "OS" thread local key
195+ // Provide the type used by the thread_local! macro to access TLS keys. This
196+ // needs to be kept in sync with the macro itself (in `local.rs`).
197+ // There are three types: "static", "fast", "OS". The "OS" thread local key
197198// type is accessed via platform-specific API calls and is slow, while the "fast"
198199// key type is accessed via code generated via LLVM, where TLS keys are set up
199200// by the elf linker. "static" is for single-threaded platforms where a global
200201// static is sufficient.
201202
202203#[ unstable( feature = "libstd_thread_internals" , issue = "none" ) ]
203- #[ cfg( target_thread_local) ]
204204#[ cfg( not( test) ) ]
205+ #[ cfg( all(
206+ target_thread_local,
207+ not( all( target_family = "wasm" , not( target_feature = "atomics" ) ) ) ,
208+ ) ) ]
205209#[ doc( hidden) ]
206210pub use self :: local:: fast:: Key as __FastLocalKeyInner;
211+
212+ // when building for tests, use real std's type
207213#[ unstable( feature = "libstd_thread_internals" , issue = "none" ) ]
208- #[ cfg( target_thread_local) ]
209- #[ cfg( test) ] // when building for tests, use real std's key
214+ #[ cfg( test) ]
215+ #[ cfg( all(
216+ target_thread_local,
217+ not( all( target_family = "wasm" , not( target_feature = "atomics" ) ) ) ,
218+ ) ) ]
210219pub use realstd:: thread:: __FastLocalKeyInner;
211220
221+ // but import the local one anyway to silence 'unused' warnings
212222#[ unstable( feature = "libstd_thread_internals" , issue = "none" ) ]
213- #[ cfg( target_thread_local) ]
214223#[ cfg( test) ]
215- pub use self :: local:: fast:: Key as __FastLocalKeyInnerUnused; // we import this anyway to silence 'unused' warnings
224+ #[ cfg( all(
225+ target_thread_local,
226+ not( all( target_family = "wasm" , not( target_feature = "atomics" ) ) ) ,
227+ ) ) ]
228+ pub use self :: local:: fast:: Key as __FastLocalKeyInnerUnused;
216229
217230#[ unstable( feature = "libstd_thread_internals" , issue = "none" ) ]
231+ #[ cfg( all(
232+ not( target_thread_local) ,
233+ not( all( target_family = "wasm" , not( target_feature = "atomics" ) ) ) ,
234+ ) ) ]
218235#[ doc( hidden) ]
219- #[ cfg( not( target_thread_local) ) ]
220236pub use self :: local:: os:: Key as __OsLocalKeyInner;
237+
221238#[ unstable( feature = "libstd_thread_internals" , issue = "none" ) ]
222239#[ cfg( all( target_family = "wasm" , not( target_feature = "atomics" ) ) ) ]
223240#[ doc( hidden) ]
0 commit comments