Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit e5e928e

Browse files
committed
Auto merge of rust-lang#118517 - petrochenkov:span2, r=<try>
[PERF-EXPERIMENT] Add second span to a span cc rust-lang#95580
2 parents 64d7e0d + b906c40 commit e5e928e

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

compiler/rustc_metadata/src/rmeta/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for SpanData {
632632
let hi = hi + source_file.translated_source_file.start_pos;
633633

634634
// Do not try to decode parent for foreign spans.
635-
SpanData { lo, hi, ctxt, parent: None }
635+
SpanData { lo, hi, ctxt, parent: None, span2: DUMMY_SP }
636636
}
637637
}
638638

compiler/rustc_span/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ pub struct SpanData {
440440
/// code was created by a macro expansion.
441441
pub ctxt: SyntaxContext,
442442
pub parent: Option<LocalDefId>,
443+
pub span2: Span,
443444
}
444445

445446
// Order spans by position in the file.
@@ -452,6 +453,7 @@ impl Ord for SpanData {
452453
// `LocalDefId` does not implement `Ord`.
453454
// The other fields are enough to determine in-file order.
454455
parent: _,
456+
span2: _,
455457
} = self;
456458
let SpanData {
457459
lo: o_lo,
@@ -460,6 +462,7 @@ impl Ord for SpanData {
460462
// `LocalDefId` does not implement `Ord`.
461463
// The other fields are enough to determine in-file order.
462464
parent: _,
465+
span2: _,
463466
} = other;
464467

465468
(s_lo, s_hi, s_ctxt).cmp(&(o_lo, o_hi, o_ctxt))

compiler/rustc_span/src/span_encoding.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,9 @@ impl Span {
132132
}
133133

134134
// Partially-interned or fully-interned format.
135-
let index =
136-
with_span_interner(|interner| interner.intern(&SpanData { lo, hi, ctxt, parent }));
135+
let index = with_span_interner(|interner| {
136+
interner.intern(&SpanData { lo, hi, ctxt, parent, span2: DUMMY_SP })
137+
});
137138
let ctxt_or_parent_or_marker = if ctxt2 <= MAX_CTXT {
138139
ctxt2 as u16 // partially-interned
139140
} else {
@@ -169,6 +170,7 @@ impl Span {
169170
hi: BytePos(self.lo_or_index + len),
170171
ctxt: SyntaxContext::from_u32(self.ctxt_or_parent_or_marker as u32),
171172
parent: None,
173+
span2: DUMMY_SP,
172174
}
173175
} else {
174176
// Inline-parent format.
@@ -182,6 +184,7 @@ impl Span {
182184
hi: BytePos(self.lo_or_index + len),
183185
ctxt: SyntaxContext::root(),
184186
parent: Some(parent),
187+
span2: DUMMY_SP,
185188
}
186189
}
187190
} else {

0 commit comments

Comments
 (0)