aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/expr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/expr.rs')
-rw-r--r--crates/ra_hir/src/expr.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs
index 29469af2c..60d997bbe 100644
--- a/crates/ra_hir/src/expr.rs
+++ b/crates/ra_hir/src/expr.rs
@@ -498,7 +498,13 @@ impl ExprCollector {
498 let then_branch = self.collect_block_opt(e.then_branch()); 498 let then_branch = self.collect_block_opt(e.then_branch());
499 let else_branch = e 499 let else_branch = e
500 .else_branch() 500 .else_branch()
501 .map(|e| self.collect_block(e)) 501 .map(|b| match b {
502 ast::ElseBranchFlavor::Block(it) => self.collect_block(it),
503 ast::ElseBranchFlavor::IfExpr(elif) => {
504 let expr: &ast::Expr = ast::Expr::cast(elif.syntax()).unwrap();
505 self.collect_expr(expr)
506 }
507 })
502 .unwrap_or_else(|| self.empty_block()); 508 .unwrap_or_else(|| self.empty_block());
503 let placeholder_pat = self.pats.alloc(Pat::Missing); 509 let placeholder_pat = self.pats.alloc(Pat::Missing);
504 let arms = vec![ 510 let arms = vec![
@@ -521,7 +527,13 @@ impl ExprCollector {
521 } else { 527 } else {
522 let condition = self.collect_expr_opt(e.condition().and_then(|c| c.expr())); 528 let condition = self.collect_expr_opt(e.condition().and_then(|c| c.expr()));
523 let then_branch = self.collect_block_opt(e.then_branch()); 529 let then_branch = self.collect_block_opt(e.then_branch());
524 let else_branch = e.else_branch().map(|e| self.collect_block(e)); 530 let else_branch = e.else_branch().map(|b| match b {
531 ast::ElseBranchFlavor::Block(it) => self.collect_block(it),
532 ast::ElseBranchFlavor::IfExpr(elif) => {
533 let expr: &ast::Expr = ast::Expr::cast(elif.syntax()).unwrap();
534 self.collect_expr(expr)
535 }
536 });
525 self.alloc_expr( 537 self.alloc_expr(
526 Expr::If { 538 Expr::If {
527 condition, 539 condition,