Skip to content

Commit bafcb26

Browse files
committed
Mark desugaring of ..= as such when lowering
1 parent c241e14 commit bafcb26

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
15231523
fn lower_expr_range_closed(&mut self, span: Span, e1: &Expr, e2: &Expr) -> hir::ExprKind<'hir> {
15241524
let e1 = self.lower_expr_mut(e1);
15251525
let e2 = self.lower_expr_mut(e2);
1526-
let fn_path = hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, self.lower_span(span));
1526+
let span = self.mark_span_with_reason(DesugaringKind::Range, self.lower_span(span), None);
1527+
let fn_path = hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, span);
15271528
let fn_expr = self.arena.alloc(self.expr(span, hir::ExprKind::Path(fn_path)));
15281529
hir::ExprKind::Call(fn_expr, arena_vec![self; e1, e2])
15291530
}
@@ -1587,8 +1588,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
15871588
),
15881589
);
15891590

1591+
let struct_span =
1592+
self.mark_span_with_reason(DesugaringKind::Range, self.lower_span(span), None);
15901593
hir::ExprKind::Struct(
1591-
self.arena.alloc(hir::QPath::LangItem(lang_item, self.lower_span(span))),
1594+
self.arena.alloc(hir::QPath::LangItem(lang_item, struct_span)),
15921595
fields,
15931596
hir::StructTailExpr::None,
15941597
)

compiler/rustc_span/src/hygiene.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,7 @@ pub enum DesugaringKind {
11621162
Await,
11631163
ForLoop,
11641164
WhileLoop,
1165+
Range,
11651166
/// `async Fn()` bound modifier
11661167
BoundModifier,
11671168
/// Calls to contract checks (`#[requires]` to precond, `#[ensures]` to postcond)
@@ -1181,6 +1182,7 @@ impl DesugaringKind {
11811182
DesugaringKind::OpaqueTy => "`impl Trait`",
11821183
DesugaringKind::ForLoop => "`for` loop",
11831184
DesugaringKind::WhileLoop => "`while` loop",
1185+
DesugaringKind::Range => "`..` or `..=` range",
11841186
DesugaringKind::BoundModifier => "trait bound modifier",
11851187
DesugaringKind::Contract => "contract check",
11861188
}

0 commit comments

Comments
 (0)