mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Auto merge of #110497 - cjgillot:span-ctxt, r=b-naber
Refactor `SyntaxContext::ctxt` logic. I'm still trying to make a test from the issue. cc `@deepink-mas` does this solve the issue? Fixes https://github.com/rust-lang/rust/issues/110230
This commit is contained in:
commit
f12a7fa00f
@ -181,19 +181,23 @@ impl Span {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn ctxt(self) -> SyntaxContext {
|
pub fn ctxt(self) -> SyntaxContext {
|
||||||
let ctxt_or_tag = self.ctxt_or_tag as u32;
|
let ctxt_or_tag = self.ctxt_or_tag as u32;
|
||||||
if ctxt_or_tag <= MAX_CTXT {
|
// Check for interned format.
|
||||||
if self.len_or_tag == LEN_TAG || self.len_or_tag & PARENT_MASK == 0 {
|
if self.len_or_tag == LEN_TAG {
|
||||||
// Inline format or interned format with inline ctxt.
|
if ctxt_or_tag == CTXT_TAG {
|
||||||
SyntaxContext::from_u32(ctxt_or_tag)
|
// Fully interned format.
|
||||||
|
let index = self.base_or_index;
|
||||||
|
with_span_interner(|interner| interner.spans[index as usize].ctxt)
|
||||||
} else {
|
} else {
|
||||||
// Inline format or interned format with inline parent.
|
// Interned format with inline ctxt.
|
||||||
// We know that the SyntaxContext is root.
|
SyntaxContext::from_u32(ctxt_or_tag)
|
||||||
SyntaxContext::root()
|
|
||||||
}
|
}
|
||||||
|
} else if self.len_or_tag & PARENT_MASK == 0 {
|
||||||
|
// Inline format with inline ctxt.
|
||||||
|
SyntaxContext::from_u32(ctxt_or_tag)
|
||||||
} else {
|
} else {
|
||||||
// Interned format.
|
// Inline format with inline parent.
|
||||||
let index = self.base_or_index;
|
// We know that the SyntaxContext is root.
|
||||||
with_span_interner(|interner| interner.spans[index as usize].ctxt)
|
SyntaxContext::root()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user