Skip to content

Commit 7bf0c00

Browse files
committed
Remove ast index mask
Signed-off-by: Hayashi Mikihiro <[email protected]>
1 parent a8b8b2b commit 7bf0c00

File tree

1 file changed

+10
-7
lines changed
  • src/tools/rust-analyzer/crates/hir-expand/src

1 file changed

+10
-7
lines changed

src/tools/rust-analyzer/crates/hir-expand/src/attrs.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,21 +175,24 @@ 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
177177
impl AttrId {
178-
const AST_INDEX_MASK: usize = 0x00FF_FFFF;
179-
const INNER_ATTR_BIT: usize = 1 << 31;
178+
const INNER_ATTR_SET_BIT: usize = 1 << 31;
180179

181180
pub fn new(id: usize, is_inner: bool) -> Self {
182-
let id = id & Self::AST_INDEX_MASK;
183-
let id = if is_inner { id | Self::INNER_ATTR_BIT } else { id };
184-
Self { id: id as u32 }
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+
}
185188
}
186189

187190
pub fn ast_index(&self) -> usize {
188-
self.id as usize & Self::AST_INDEX_MASK
191+
self.id as usize & !Self::INNER_ATTR_SET_BIT
189192
}
190193

191194
pub fn is_inner_attr(&self) -> bool {
192-
(self.id as usize) & Self::INNER_ATTR_BIT != 0
195+
(self.id as usize) & Self::INNER_ATTR_SET_BIT != 0
193196
}
194197
}
195198

0 commit comments

Comments
 (0)