Skip to content

[PERF-EXPERIMENT] Add second span to a span #118517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for SpanData {
let hi = hi + source_file.translated_source_file.start_pos;

// Do not try to decode parent for foreign spans.
SpanData { lo, hi, ctxt, parent: None }
SpanData { lo, hi, ctxt, parent: None, span2: DUMMY_SP }
}
}

Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ pub struct SpanData {
/// code was created by a macro expansion.
pub ctxt: SyntaxContext,
pub parent: Option<LocalDefId>,
pub span2: Span,
}

// Order spans by position in the file.
Expand All @@ -452,6 +453,7 @@ impl Ord for SpanData {
// `LocalDefId` does not implement `Ord`.
// The other fields are enough to determine in-file order.
parent: _,
span2: _,
} = self;
let SpanData {
lo: o_lo,
Expand All @@ -460,6 +462,7 @@ impl Ord for SpanData {
// `LocalDefId` does not implement `Ord`.
// The other fields are enough to determine in-file order.
parent: _,
span2: _,
} = other;

(s_lo, s_hi, s_ctxt).cmp(&(o_lo, o_hi, o_ctxt))
Expand Down
7 changes: 5 additions & 2 deletions compiler/rustc_span/src/span_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ impl Span {
}

// Partially-interned or fully-interned format.
let index =
with_span_interner(|interner| interner.intern(&SpanData { lo, hi, ctxt, parent }));
let index = with_span_interner(|interner| {
interner.intern(&SpanData { lo, hi, ctxt, parent, span2: DUMMY_SP })
});
let ctxt_or_parent_or_marker = if ctxt2 <= MAX_CTXT {
ctxt2 as u16 // partially-interned
} else {
Expand Down Expand Up @@ -169,6 +170,7 @@ impl Span {
hi: BytePos(self.lo_or_index + len),
ctxt: SyntaxContext::from_u32(self.ctxt_or_parent_or_marker as u32),
parent: None,
span2: DUMMY_SP,
}
} else {
// Inline-parent format.
Expand All @@ -182,6 +184,7 @@ impl Span {
hi: BytePos(self.lo_or_index + len),
ctxt: SyntaxContext::root(),
parent: Some(parent),
span2: DUMMY_SP,
}
}
} else {
Expand Down