Skip to content

Commit 0087253

Browse files
committed
early return on duplicate span lowerings
1 parent 2fcbda6 commit 0087253

File tree

1 file changed

+7
-0
lines changed
  • compiler/rustc_ast_lowering/src

1 file changed

+7
-0
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,13 @@ struct SpanLowerer {
220220
impl SpanLowerer {
221221
fn lower(&self, span: Span) -> Span {
222222
if self.is_incremental {
223+
// early return: span lowering takes some time since it accesses the query dependency graph
224+
// to make sure we rerun the right code paths when spans change. When we've already lowered a span,
225+
// or don't have to, bail out ASAP.
226+
if span.is_dummy() || span.parent().is_some_and(|i| i == self.def_id) {
227+
return span;
228+
}
229+
223230
span.with_parent(Some(self.def_id))
224231
} else {
225232
// Do not make spans relative when not using incremental compilation.

0 commit comments

Comments
 (0)