@@ -123,15 +123,15 @@ impl RawAttrs {
123123 ( None , entries @ Some ( _) ) => Self { entries } ,
124124 ( Some ( entries) , None ) => Self { entries : Some ( entries. clone ( ) ) } ,
125125 ( Some ( a) , Some ( b) ) => {
126- let last_ast_index = a. slice . last ( ) . map_or ( 0 , |it| it. id . ast_index ( ) + 1 ) as u32 ;
126+ let last_ast_index = a. slice . last ( ) . map_or ( 0 , |it| it. id . ast_index ( ) + 1 ) ;
127127 let items = a
128128 . slice
129129 . iter ( )
130130 . cloned ( )
131131 . chain ( b. slice . iter ( ) . map ( |it| {
132132 let mut it = it. clone ( ) ;
133- let id = it. id . ast_index ( ) as u32 + last_ast_index;
134- it. id = AttrId :: new ( id as usize , it. id . is_inner_attr ( ) ) ;
133+ let id = it. id . ast_index ( ) + last_ast_index;
134+ it. id = AttrId :: new ( id, it. id . is_inner_attr ( ) ) ;
135135 it
136136 } ) )
137137 . collect :: < Vec < _ > > ( ) ;
@@ -175,24 +175,20 @@ pub struct AttrId {
175175// FIXME: This only handles a single level of cfg_attr nesting
176176// that is `#[cfg_attr(all(), cfg_attr(all(), cfg(any())))]` breaks again
177177impl AttrId {
178- const INNER_ATTR_SET_BIT : usize = 1 << 31 ;
178+ const INNER_ATTR_SET_BIT : u32 = 1 << 31 ;
179179
180180 pub fn new ( id : usize , is_inner : bool ) -> Self {
181- Self {
182- id : if is_inner {
183- id | Self :: INNER_ATTR_SET_BIT
184- } else {
185- id & !Self :: INNER_ATTR_SET_BIT
186- } as u32 ,
187- }
181+ assert ! ( id <= !Self :: INNER_ATTR_SET_BIT as usize ) ;
182+ let id = id as u32 ;
183+ Self { id : if is_inner { id | Self :: INNER_ATTR_SET_BIT } else { id } }
188184 }
189185
190186 pub fn ast_index ( & self ) -> usize {
191- self . id as usize & !Self :: INNER_ATTR_SET_BIT
187+ ( self . id & !Self :: INNER_ATTR_SET_BIT ) as usize
192188 }
193189
194190 pub fn is_inner_attr ( & self ) -> bool {
195- ( self . id as usize ) & Self :: INNER_ATTR_SET_BIT != 0
191+ self . id & Self :: INNER_ATTR_SET_BIT != 0
196192 }
197193}
198194
0 commit comments