Skip to content

Commit fa1f706

Browse files
committed
Auto merge of #149060 - jdonszelmann:duplicate-span-lowering, r=WaffleLapkin
early return on duplicate span lowerings `@bors2` try
2 parents 1d6c526 + 0087253 commit fa1f706

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
@@ -225,6 +225,13 @@ struct SpanLowerer {
225225
impl SpanLowerer {
226226
fn lower(&self, span: Span) -> Span {
227227
if self.is_incremental {
228+
// early return: span lowering takes some time since it accesses the query dependency graph
229+
// to make sure we rerun the right code paths when spans change. When we've already lowered a span,
230+
// or don't have to, bail out ASAP.
231+
if span.is_dummy() || span.parent().is_some_and(|i| i == self.def_id) {
232+
return span;
233+
}
234+
228235
span.with_parent(Some(self.def_id))
229236
} else {
230237
// Do not make spans relative when not using incremental compilation.

0 commit comments

Comments
 (0)