@@ -4,7 +4,7 @@ use std::collections::BTreeMap;
44use std:: hash:: Hash ;
55use std:: num:: NonZeroU32 ;
66use std:: ops:: { Index , IndexMut } ;
7- use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
7+ use std:: sync:: atomic:: { AtomicU32 , Ordering } ;
88
99use super :: fxhash:: FxHashMap ;
1010
@@ -13,12 +13,12 @@ pub(super) type Handle = NonZeroU32;
1313/// A store that associates values of type `T` with numeric handles. A value can
1414/// be looked up using its handle.
1515pub ( super ) struct OwnedStore < T : ' static > {
16- counter : & ' static AtomicUsize ,
16+ counter : & ' static AtomicU32 ,
1717 data : BTreeMap < Handle , T > ,
1818}
1919
2020impl < T > OwnedStore < T > {
21- pub ( super ) fn new ( counter : & ' static AtomicUsize ) -> Self {
21+ pub ( super ) fn new ( counter : & ' static AtomicU32 ) -> Self {
2222 // Ensure the handle counter isn't 0, which would panic later,
2323 // when `NonZeroU32::new` (aka `Handle::new`) is called in `alloc`.
2424 assert_ne ! ( counter. load( Ordering :: SeqCst ) , 0 ) ;
@@ -30,7 +30,7 @@ impl<T> OwnedStore<T> {
3030impl < T > OwnedStore < T > {
3131 pub ( super ) fn alloc ( & mut self , x : T ) -> Handle {
3232 let counter = self . counter . fetch_add ( 1 , Ordering :: SeqCst ) ;
33- let handle = Handle :: new ( counter as u32 ) . expect ( "`proc_macro` handle counter overflowed" ) ;
33+ let handle = Handle :: new ( counter) . expect ( "`proc_macro` handle counter overflowed" ) ;
3434 assert ! ( self . data. insert( handle, x) . is_none( ) ) ;
3535 handle
3636 }
@@ -60,7 +60,7 @@ pub(super) struct InternedStore<T: 'static> {
6060}
6161
6262impl < T : Copy + Eq + Hash > InternedStore < T > {
63- pub ( super ) fn new ( counter : & ' static AtomicUsize ) -> Self {
63+ pub ( super ) fn new ( counter : & ' static AtomicU32 ) -> Self {
6464 InternedStore { owned : OwnedStore :: new ( counter) , interner : FxHashMap :: default ( ) }
6565 }
6666
0 commit comments