Skip to content

Commit

Permalink
Lower if let before the arms.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Nov 23, 2020
1 parent ae6aa22 commit 6e17ab5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/expr.rs
Expand Up @@ -353,7 +353,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
let else_arm = self.arm(else_pat, else_expr);

// Handle then + scrutinee:
let then_expr = self.lower_block_expr(then);
let (then_pat, scrutinee, desugar) = match cond.kind {
// `<pat> => <then>`:
ExprKind::Let(ref pat, ref scrutinee) => {
Expand All @@ -375,6 +374,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
(pat, cond, hir::MatchSource::IfDesugar { contains_else_clause })
}
};
let then_expr = self.lower_block_expr(then);
let then_arm = self.arm(then_pat, self.arena.alloc(then_expr));

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

// Handle then + scrutinee:
let then_expr = self.lower_block_expr(body);
let (then_pat, scrutinee, desugar, source) = match cond.kind {
ExprKind::Let(ref pat, ref scrutinee) => {
// to:
Expand Down Expand Up @@ -440,6 +439,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
(pat, cond, hir::MatchSource::WhileDesugar, hir::LoopSource::While)
}
};
let then_expr = self.lower_block_expr(body);
let then_arm = self.arm(then_pat, self.arena.alloc(then_expr));

// `match <scrutinee> { ... }`
Expand Down

0 comments on commit 6e17ab5

Please sign in to comment.