about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2023-02-11 17:37:52 +0000
committerCamille GILLOT <gillot.camille@gmail.com>2023-02-11 17:46:22 +0000
commite80afa6501a700cb7bd356ea1c26190f6e21e79a (patch)
tree49fae8baa631be6574f8d0f61e4e8ef6d6676cea /compiler
parent8cca42a47f5d574c8f7302c98c3f918cdc772fbb (diff)
downloadrust-e80afa6501a700cb7bd356ea1c26190f6e21e79a.tar.gz
rust-e80afa6501a700cb7bd356ea1c26190f6e21e79a.zip
Intern span when length is MAX_LEN with parent.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_span/src/span_encoding.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_span/src/span_encoding.rs b/compiler/rustc_span/src/span_encoding.rs
index d48c4f7e5a8..c600298c51a 100644
--- a/compiler/rustc_span/src/span_encoding.rs
+++ b/compiler/rustc_span/src/span_encoding.rs
@@ -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,