@@ -18,7 +18,6 @@ use cell::UnsafeCell;
18
18
19
19
// Sure wish we had macro hygiene, no?
20
20
#[ doc( hidden) ]
21
- #[ unstable( feature = "thread_local_internals" ) ]
22
21
pub mod __impl {
23
22
pub use super :: imp:: Key as KeyInner ;
24
23
pub use super :: imp:: destroy_value;
@@ -78,12 +77,10 @@ pub struct LocalKey<T> {
78
77
// This is trivially devirtualizable by LLVM because we never store anything
79
78
// to this field and rustc can declare the `static` as constant as well.
80
79
#[ doc( hidden) ]
81
- #[ unstable( feature = "thread_local_internals" ) ]
82
80
pub inner : fn ( ) -> & ' static __impl:: KeyInner < UnsafeCell < Option < T > > > ,
83
81
84
82
// initialization routine to invoke to create a value
85
83
#[ doc( hidden) ]
86
- #[ unstable( feature = "thread_local_internals" ) ]
87
84
pub init : fn ( ) -> T ,
88
85
}
89
86
@@ -297,36 +294,31 @@ impl<T: 'static> LocalKey<T> {
297
294
}
298
295
299
296
#[ cfg( all( any( target_os = "macos" , target_os = "linux" ) , not( target_arch = "aarch64" ) ) ) ]
297
+ #[ doc( hidden) ]
300
298
mod imp {
301
299
use prelude:: v1:: * ;
302
300
303
301
use cell:: UnsafeCell ;
304
302
use intrinsics;
305
303
use ptr;
306
304
307
- #[ doc( hidden) ]
308
- #[ unstable( feature = "thread_local_internals" ) ]
309
305
pub struct Key < T > {
310
306
// Place the inner bits in an `UnsafeCell` to currently get around the
311
307
// "only Sync statics" restriction. This allows any type to be placed in
312
308
// the cell.
313
309
//
314
310
// Note that all access requires `T: 'static` so it can't be a type with
315
311
// any borrowed pointers still.
316
- #[ unstable( feature = "thread_local_internals" ) ]
317
312
pub inner : UnsafeCell < T > ,
318
313
319
314
// Metadata to keep track of the state of the destructor. Remember that
320
315
// these variables are thread-local, not global.
321
- #[ unstable( feature = "thread_local_internals" ) ]
322
316
pub dtor_registered : UnsafeCell < bool > , // should be Cell
323
- #[ unstable( feature = "thread_local_internals" ) ]
324
317
pub dtor_running : UnsafeCell < bool > , // should be Cell
325
318
}
326
319
327
320
unsafe impl < T > :: marker:: Sync for Key < T > { }
328
321
329
- #[ doc( hidden) ]
330
322
impl < T > Key < T > {
331
323
pub unsafe fn get ( & ' static self ) -> Option < & ' static T > {
332
324
if intrinsics:: needs_drop :: < T > ( ) && * self . dtor_running . get ( ) {
@@ -422,8 +414,6 @@ mod imp {
422
414
_tlv_atexit ( dtor, t) ;
423
415
}
424
416
425
- #[ doc( hidden) ]
426
- #[ unstable( feature = "thread_local_internals" ) ]
427
417
pub unsafe extern fn destroy_value < T > ( ptr : * mut u8 ) {
428
418
let ptr = ptr as * mut Key < T > ;
429
419
// Right before we run the user destructor be sure to flag the
@@ -435,6 +425,7 @@ mod imp {
435
425
}
436
426
437
427
#[ cfg( any( not( any( target_os = "macos" , target_os = "linux" ) ) , target_arch = "aarch64" ) ) ]
428
+ #[ doc( hidden) ]
438
429
mod imp {
439
430
use prelude:: v1:: * ;
440
431
@@ -444,16 +435,12 @@ mod imp {
444
435
use ptr;
445
436
use sys_common:: thread_local:: StaticKey as OsStaticKey ;
446
437
447
- #[ doc( hidden) ]
448
- #[ unstable( feature = "thread_local_internals" ) ]
449
438
pub struct Key < T > {
450
439
// Statically allocated initialization expression, using an `UnsafeCell`
451
440
// for the same reasons as above.
452
- #[ unstable( feature = "thread_local_internals" ) ]
453
441
pub inner : UnsafeCell < T > ,
454
442
455
443
// OS-TLS key that we'll use to key off.
456
- #[ unstable( feature = "thread_local_internals" ) ]
457
444
pub os : OsStaticKey ,
458
445
}
459
446
@@ -464,7 +451,6 @@ mod imp {
464
451
value : T ,
465
452
}
466
453
467
- #[ doc( hidden) ]
468
454
impl < T > Key < T > {
469
455
pub unsafe fn get ( & ' static self ) -> Option < & ' static T > {
470
456
self . ptr ( ) . map ( |p| & * p)
@@ -489,14 +475,12 @@ mod imp {
489
475
key : self ,
490
476
value : mem:: transmute_copy ( & self . inner ) ,
491
477
} ;
492
- let ptr: * mut Value < T > = boxed:: into_raw ( ptr) ;
478
+ let ptr = boxed:: into_raw ( ptr) ;
493
479
self . os . set ( ptr as * mut u8 ) ;
494
480
Some ( & mut ( * ptr) . value as * mut T )
495
481
}
496
482
}
497
483
498
- #[ doc( hidden) ]
499
- #[ unstable( feature = "thread_local_internals" ) ]
500
484
pub unsafe extern fn destroy_value < T : ' static > ( ptr : * mut u8 ) {
501
485
// The OS TLS ensures that this key contains a NULL value when this
502
486
// destructor starts to run. We set it back to a sentinel value of 1 to
@@ -505,7 +489,7 @@ mod imp {
505
489
//
506
490
// Note that to prevent an infinite loop we reset it back to null right
507
491
// before we return from the destructor ourselves.
508
- let ptr: Box < Value < T > > = Box :: from_raw ( ptr as * mut Value < T > ) ;
492
+ let ptr = Box :: from_raw ( ptr as * mut Value < T > ) ;
509
493
let key = ptr. key ;
510
494
key. os . set ( 1 as * mut u8 ) ;
511
495
drop ( ptr) ;
0 commit comments