mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Remove ast index mask
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
This commit is contained in:
parent
52b523aabe
commit
ab4ba5cd29
@ -175,21 +175,24 @@ pub struct AttrId {
|
|||||||
// FIXME: This only handles a single level of cfg_attr nesting
|
// FIXME: This only handles a single level of cfg_attr nesting
|
||||||
// that is `#[cfg_attr(all(), cfg_attr(all(), cfg(any())))]` breaks again
|
// that is `#[cfg_attr(all(), cfg_attr(all(), cfg(any())))]` breaks again
|
||||||
impl AttrId {
|
impl AttrId {
|
||||||
const AST_INDEX_MASK: usize = 0x00FF_FFFF;
|
const INNER_ATTR_SET_BIT: usize = 1 << 31;
|
||||||
const INNER_ATTR_BIT: usize = 1 << 31;
|
|
||||||
|
|
||||||
pub fn new(id: usize, is_inner: bool) -> Self {
|
pub fn new(id: usize, is_inner: bool) -> Self {
|
||||||
let id = id & Self::AST_INDEX_MASK;
|
Self {
|
||||||
let id = if is_inner { id | Self::INNER_ATTR_BIT } else { id };
|
id: if is_inner {
|
||||||
Self { id: id as u32 }
|
id | Self::INNER_ATTR_SET_BIT
|
||||||
|
} else {
|
||||||
|
id & !Self::INNER_ATTR_SET_BIT
|
||||||
|
} as u32,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ast_index(&self) -> usize {
|
pub fn ast_index(&self) -> usize {
|
||||||
self.id as usize & Self::AST_INDEX_MASK
|
self.id as usize & !Self::INNER_ATTR_SET_BIT
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_inner_attr(&self) -> bool {
|
pub fn is_inner_attr(&self) -> bool {
|
||||||
(self.id as usize) & Self::INNER_ATTR_BIT != 0
|
(self.id as usize) & Self::INNER_ATTR_SET_BIT != 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user