Skip to content

Commit 78cce17

Browse files
committed
Remove ast index mask
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
1 parent 605e1b6 commit 78cce17

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

crates/hir-expand/src/attrs.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -181,21 +181,24 @@ pub struct AttrId {
181181
// FIXME: This only handles a single level of cfg_attr nesting
182182
// that is `#[cfg_attr(all(), cfg_attr(all(), cfg(any())))]` breaks again
183183
impl AttrId {
184-
const AST_INDEX_MASK: usize = 0x00FF_FFFF;
185-
const INNER_ATTR_BIT: usize = 1 << 31;
184+
const INNER_ATTR_SET_BIT: usize = 1 << 31;
186185

187186
pub fn new(id: usize, is_inner: bool) -> Self {
188-
let id = id & Self::AST_INDEX_MASK;
189-
let id = if is_inner { id | Self::INNER_ATTR_BIT } else { id };
190-
Self { id: id as u32 }
187+
Self {
188+
id: if is_inner {
189+
id | Self::INNER_ATTR_SET_BIT
190+
} else {
191+
id & !Self::INNER_ATTR_SET_BIT
192+
} as u32,
193+
}
191194
}
192195

193196
pub fn ast_index(&self) -> usize {
194-
self.id as usize & Self::AST_INDEX_MASK
197+
self.id as usize & !Self::INNER_ATTR_SET_BIT
195198
}
196199

197200
pub fn is_inner_attr(&self) -> bool {
198-
(self.id as usize) & Self::INNER_ATTR_BIT != 0
201+
(self.id as usize) & Self::INNER_ATTR_SET_BIT != 0
199202
}
200203
}
201204

0 commit comments

Comments
 (0)