about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2021-02-19 17:00:31 -0800
committerEsteban Küber <esteban@kuber.com.ar>2021-02-19 17:00:31 -0800
commitf0637e4e185e8c3dda694004d1dfd31126ed1fbd (patch)
treede8f1bd64394d24f136003f45252145a46eb055c /compiler/rustc_ast_lowering/src
parent8fe989dd768f5dfdb0fc90933f3f74fa4579fefd (diff)
downloadrust-f0637e4e185e8c3dda694004d1dfd31126ed1fbd.tar.gz
rust-f0637e4e185e8c3dda694004d1dfd31126ed1fbd.zip
Lower condition of `if` expression before it's "then" block
Fix #82290, fix #82250.
Diffstat (limited to 'compiler/rustc_ast_lowering/src')
-rw-r--r--compiler/rustc_ast_lowering/src/expr.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs
index b118c0eaed4..6d44feec2c4 100644
--- a/compiler/rustc_ast_lowering/src/expr.rs
+++ b/compiler/rustc_ast_lowering/src/expr.rs
@@ -347,8 +347,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
     ) -> hir::ExprKind<'hir> {
         macro_rules! make_if {
             ($opt:expr) => {{
+                let cond = self.lower_expr(cond);
                 let then_expr = self.lower_block_expr(then);
-                hir::ExprKind::If(self.lower_expr(cond), self.arena.alloc(then_expr), $opt)
+                hir::ExprKind::If(cond, self.arena.alloc(then_expr), $opt)
             }};
         }
         if let Some(rslt) = else_opt {