Skip to content

Commit

Permalink
Rollup merge of #107931 - cjgillot:issue-107353, r=WaffleLapkin
Browse files Browse the repository at this point in the history
Intern span when length is MAX_LEN with parent.

Fixes #107353
  • Loading branch information
matthiaskrgr authored Feb 13, 2023
2 parents 8674adc + 84bb373 commit 3e5c11b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compiler/rustc_span/src/span_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,16 @@ impl Span {
// Inline format with parent.
let len_or_tag = len_or_tag | PARENT_MASK;
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 };
}
} else {
// Inline format with ctxt.
debug_assert_ne!(len_or_tag, LEN_TAG);
return Span {
base_or_index: base,
len_or_tag: len as u16,
Expand Down
Loading

0 comments on commit 3e5c11b

Please sign in to comment.