Skip to content

Commit 3e5c11b

Browse files
authored
Rollup merge of #107931 - cjgillot:issue-107353, r=WaffleLapkin
Intern span when length is MAX_LEN with parent. Fixes #107353
2 parents 8674adc + 84bb373 commit 3e5c11b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

compiler/rustc_span/src/span_encoding.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,16 @@ impl Span {
110110
// Inline format with parent.
111111
let len_or_tag = len_or_tag | PARENT_MASK;
112112
let parent2 = parent.local_def_index.as_u32();
113-
if ctxt2 == SyntaxContext::root().as_u32() && parent2 <= MAX_CTXT {
113+
if ctxt2 == SyntaxContext::root().as_u32()
114+
&& parent2 <= MAX_CTXT
115+
&& len_or_tag < LEN_TAG
116+
{
117+
debug_assert_ne!(len_or_tag, LEN_TAG);
114118
return Span { base_or_index: base, len_or_tag, ctxt_or_tag: parent2 as u16 };
115119
}
116120
} else {
117121
// Inline format with ctxt.
122+
debug_assert_ne!(len_or_tag, LEN_TAG);
118123
return Span {
119124
base_or_index: base,
120125
len_or_tag: len as u16,

0 commit comments

Comments
 (0)