@@ -123,15 +123,15 @@ impl RawAttrs {
123
123
( None , entries @ Some ( _) ) => Self { entries } ,
124
124
( Some ( entries) , None ) => Self { entries : Some ( entries. clone ( ) ) } ,
125
125
( 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 ) ;
127
127
let items = a
128
128
. slice
129
129
. iter ( )
130
130
. cloned ( )
131
131
. chain ( b. slice . iter ( ) . map ( |it| {
132
132
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 ( ) ) ;
135
135
it
136
136
} ) )
137
137
. collect :: < Vec < _ > > ( ) ;
@@ -175,24 +175,20 @@ pub struct AttrId {
175
175
// FIXME: This only handles a single level of cfg_attr nesting
176
176
// that is `#[cfg_attr(all(), cfg_attr(all(), cfg(any())))]` breaks again
177
177
impl AttrId {
178
- const INNER_ATTR_SET_BIT : usize = 1 << 31 ;
178
+ const INNER_ATTR_SET_BIT : u32 = 1 << 31 ;
179
179
180
180
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 } }
188
184
}
189
185
190
186
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
192
188
}
193
189
194
190
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
196
192
}
197
193
}
198
194
0 commit comments