File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ use symbol::Symbol;
31
31
use tokenstream:: { TokenStream , TokenTree , Delimited } ;
32
32
use util:: ThinVec ;
33
33
34
- use std:: cell:: { RefCell , Cell } ;
34
+ use std:: cell:: RefCell ;
35
35
use std:: iter;
36
36
37
37
thread_local ! {
@@ -419,16 +419,14 @@ pub fn mk_spanned_word_item(sp: Span, name: Name) -> MetaItem {
419
419
MetaItem { span : sp, name : name, node : MetaItemKind :: Word }
420
420
}
421
421
422
+ pub fn mk_attr_id ( ) -> AttrId {
423
+ use std:: sync:: atomic:: AtomicUsize ;
424
+ use std:: sync:: atomic:: Ordering ;
422
425
426
+ static NEXT_ATTR_ID : AtomicUsize = AtomicUsize :: new ( 0 ) ;
423
427
424
- thread_local ! { static NEXT_ATTR_ID : Cell <usize > = Cell :: new( 0 ) }
425
-
426
- pub fn mk_attr_id ( ) -> AttrId {
427
- let id = NEXT_ATTR_ID . with ( |slot| {
428
- let r = slot. get ( ) ;
429
- slot. set ( r + 1 ) ;
430
- r
431
- } ) ;
428
+ let id = NEXT_ATTR_ID . fetch_add ( 1 , Ordering :: SeqCst ) ;
429
+ assert ! ( id != :: std:: usize :: MAX ) ;
432
430
AttrId ( id)
433
431
}
434
432
Original file line number Diff line number Diff line change 24
24
#![ feature( rustc_diagnostic_macros) ]
25
25
#![ feature( match_default_bindings) ]
26
26
#![ feature( i128_type) ]
27
+ #![ feature( const_atomic_usize_new) ]
27
28
28
29
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
29
30
#[ allow( unused_extern_crates) ]
You can’t perform that action at this time.
0 commit comments