1
Fork 0

Rollup merge of #82308 - estebank:issue-82290, r=lcnr

Lower condition of `if` expression before it's "then" block

Fix #82290, fix #82250.
This commit is contained in:
Dylan DPC 2021-02-23 16:10:27 +01:00 committed by GitHub
commit 269f39922b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 1 deletions

View file

@ -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 {