Skip to content

Commit 591267e

Browse files
Auto merge of #149060 - jdonszelmann:duplicate-span-lowering, r=<try>
early return on duplicate span lowerings
2 parents c199562 + 7e0afd1 commit 591267e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
104104
items: &[Box<Item>],
105105
spans: &ModSpans,
106106
) -> &'hir hir::Mod<'hir> {
107+
println!("{:?} {:?}", spans.inner_span, spans.inner_span.parent());
107108
self.arena.alloc(hir::Mod {
108109
spans: hir::ModSpans {
109110
inner_span: self.lower_span(spans.inner_span),

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,23 @@ struct SpanLowerer {
225225
impl SpanLowerer {
226226
fn lower(&self, span: Span) -> Span {
227227
if self.is_incremental {
228+
// early return
229+
if span.parent().is_some_and(|i| i == self.def_id) {
230+
return span;
231+
}
232+
233+
// #[cfg(debug_assertions)]
234+
// {
235+
// if !span.is_dummy()
236+
// && let Some(p) = span.parent()
237+
// {
238+
// assert!(
239+
// p != self.def_id,
240+
// "duplicate span lowering detected, parent of span {span:?} was already set to {:?}",
241+
// self.def_id
242+
// );
243+
// }
244+
// }
228245
span.with_parent(Some(self.def_id))
229246
} else {
230247
// Do not make spans relative when not using incremental compilation.

0 commit comments

Comments
 (0)