Skip to content

Commit 0ae7320

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

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 2 additions & 1 deletion
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
}

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 => "`..=` range",
11841186
DesugaringKind::BoundModifier => "trait bound modifier",
11851187
DesugaringKind::Contract => "contract check",
11861188
}

0 commit comments

Comments
 (0)