@@ -192,32 +192,49 @@ pub use scoped::{scope, Scope, ScopedJoinHandle};
192
192
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
193
193
pub use self :: local:: { AccessError , LocalKey } ;
194
194
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
197
198
// type is accessed via platform-specific API calls and is slow, while the "fast"
198
199
// key type is accessed via code generated via LLVM, where TLS keys are set up
199
200
// by the elf linker. "static" is for single-threaded platforms where a global
200
201
// static is sufficient.
201
202
202
203
#[ unstable( feature = "libstd_thread_internals" , issue = "none" ) ]
203
- #[ cfg( target_thread_local) ]
204
204
#[ cfg( not( test) ) ]
205
+ #[ cfg( all(
206
+ target_thread_local,
207
+ not( all( target_family = "wasm" , not( target_feature = "atomics" ) ) ) ,
208
+ ) ) ]
205
209
#[ doc( hidden) ]
206
210
pub use self :: local:: fast:: Key as __FastLocalKeyInner;
211
+
212
+ // when building for tests, use real std's type
207
213
#[ 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
+ ) ) ]
210
219
pub use realstd:: thread:: __FastLocalKeyInner;
211
220
221
+ // but import the local one anyway to silence 'unused' warnings
212
222
#[ unstable( feature = "libstd_thread_internals" , issue = "none" ) ]
213
- #[ cfg( target_thread_local) ]
214
223
#[ 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;
216
229
217
230
#[ 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
+ ) ) ]
218
235
#[ doc( hidden) ]
219
- #[ cfg( not( target_thread_local) ) ]
220
236
pub use self :: local:: os:: Key as __OsLocalKeyInner;
237
+
221
238
#[ unstable( feature = "libstd_thread_internals" , issue = "none" ) ]
222
239
#[ cfg( all( target_family = "wasm" , not( target_feature = "atomics" ) ) ) ]
223
240
#[ doc( hidden) ]
0 commit comments