Skip to content

Commit 6e17ab5

Browse files
committed
Lower if let before the arms.
1 parent ae6aa22 commit 6e17ab5

File tree

1 file changed

+2
-2
lines changed
  • compiler/rustc_ast_lowering/src

1 file changed

+2
-2
lines changed

compiler/rustc_ast_lowering/src/expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
353353
let else_arm = self.arm(else_pat, else_expr);
354354

355355
// Handle then + scrutinee:
356-
let then_expr = self.lower_block_expr(then);
357356
let (then_pat, scrutinee, desugar) = match cond.kind {
358357
// `<pat> => <then>`:
359358
ExprKind::Let(ref pat, ref scrutinee) => {
@@ -375,6 +374,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
375374
(pat, cond, hir::MatchSource::IfDesugar { contains_else_clause })
376375
}
377376
};
377+
let then_expr = self.lower_block_expr(then);
378378
let then_arm = self.arm(then_pat, self.arena.alloc(then_expr));
379379

380380
hir::ExprKind::Match(scrutinee, arena_vec![self; then_arm, else_arm], desugar)
@@ -400,7 +400,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
400400
};
401401

402402
// Handle then + scrutinee:
403-
let then_expr = self.lower_block_expr(body);
404403
let (then_pat, scrutinee, desugar, source) = match cond.kind {
405404
ExprKind::Let(ref pat, ref scrutinee) => {
406405
// to:
@@ -440,6 +439,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
440439
(pat, cond, hir::MatchSource::WhileDesugar, hir::LoopSource::While)
441440
}
442441
};
442+
let then_expr = self.lower_block_expr(body);
443443
let then_arm = self.arm(then_pat, self.arena.alloc(then_expr));
444444

445445
// `match <scrutinee> { ... }`

0 commit comments

Comments
 (0)