1
Fork 0

Rollup merge of #107931 - cjgillot:issue-107353, r=WaffleLapkin

Intern span when length is MAX_LEN with parent.

Fixes https://github.com/rust-lang/rust/issues/107353
This commit is contained in:
Matthias Krüger 2023-02-13 11:34:58 +01:00 committed by GitHub
commit 3e5c11b855
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View file

@ -110,11 +110,16 @@ impl Span {
// Inline format with parent. // Inline format with parent.
let len_or_tag = len_or_tag | PARENT_MASK; let len_or_tag = len_or_tag | PARENT_MASK;
let parent2 = parent.local_def_index.as_u32(); let parent2 = parent.local_def_index.as_u32();
if ctxt2 == SyntaxContext::root().as_u32() && parent2 <= MAX_CTXT { if ctxt2 == SyntaxContext::root().as_u32()
&& parent2 <= MAX_CTXT
&& len_or_tag < LEN_TAG
{
debug_assert_ne!(len_or_tag, LEN_TAG);
return Span { base_or_index: base, len_or_tag, ctxt_or_tag: parent2 as u16 }; return Span { base_or_index: base, len_or_tag, ctxt_or_tag: parent2 as u16 };
} }
} else { } else {
// Inline format with ctxt. // Inline format with ctxt.
debug_assert_ne!(len_or_tag, LEN_TAG);
return Span { return Span {
base_or_index: base, base_or_index: base,
len_or_tag: len as u16, len_or_tag: len as u16,

File diff suppressed because one or more lines are too long