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;
3131use tokenstream:: { TokenStream , TokenTree , Delimited } ;
3232use util:: ThinVec ;
3333
34- use std:: cell:: { RefCell , Cell } ;
34+ use std:: cell:: RefCell ;
3535use std:: iter;
3636
3737thread_local ! {
@@ -419,16 +419,14 @@ pub fn mk_spanned_word_item(sp: Span, name: Name) -> MetaItem {
419419 MetaItem { span : sp, name : name, node : MetaItemKind :: Word }
420420}
421421
422+ pub fn mk_attr_id ( ) -> AttrId {
423+ use std:: sync:: atomic:: AtomicUsize ;
424+ use std:: sync:: atomic:: Ordering ;
422425
426+ static NEXT_ATTR_ID : AtomicUsize = AtomicUsize :: new ( 0 ) ;
423427
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 ) ;
432430 AttrId ( id)
433431}
434432
Original file line number Diff line number Diff line change 2424#![ feature( rustc_diagnostic_macros) ]
2525#![ feature( match_default_bindings) ]
2626#![ feature( i128_type) ]
27+ #![ feature( const_atomic_usize_new) ]
2728
2829// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
2930#[ allow( unused_extern_crates) ]
You can’t perform that action at this time.
0 commit comments