diff options
Diffstat (limited to 'crates/ra_hir/src/expr.rs')
-rw-r--r-- | crates/ra_hir/src/expr.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index 83e913e4a..37aa24677 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -219,7 +219,7 @@ pub use ra_syntax::ast::BinOp as BinaryOp; | |||
219 | #[derive(Debug, Clone, Eq, PartialEq)] | 219 | #[derive(Debug, Clone, Eq, PartialEq)] |
220 | pub struct MatchArm { | 220 | pub struct MatchArm { |
221 | pub pats: Vec<PatId>, | 221 | pub pats: Vec<PatId>, |
222 | // guard: Option<ExprId>, // TODO | 222 | pub guard: Option<ExprId>, |
223 | pub expr: ExprId, | 223 | pub expr: ExprId, |
224 | } | 224 | } |
225 | 225 | ||
@@ -515,10 +515,12 @@ impl ExprCollector { | |||
515 | MatchArm { | 515 | MatchArm { |
516 | pats: vec![pat], | 516 | pats: vec![pat], |
517 | expr: then_branch, | 517 | expr: then_branch, |
518 | guard: None, | ||
518 | }, | 519 | }, |
519 | MatchArm { | 520 | MatchArm { |
520 | pats: vec![placeholder_pat], | 521 | pats: vec![placeholder_pat], |
521 | expr: else_branch, | 522 | expr: else_branch, |
523 | guard: None, | ||
522 | }, | 524 | }, |
523 | ]; | 525 | ]; |
524 | self.alloc_expr( | 526 | self.alloc_expr( |
@@ -617,6 +619,10 @@ impl ExprCollector { | |||
617 | .map(|arm| MatchArm { | 619 | .map(|arm| MatchArm { |
618 | pats: arm.pats().map(|p| self.collect_pat(p)).collect(), | 620 | pats: arm.pats().map(|p| self.collect_pat(p)).collect(), |
619 | expr: self.collect_expr_opt(arm.expr()), | 621 | expr: self.collect_expr_opt(arm.expr()), |
622 | guard: arm | ||
623 | .guard() | ||
624 | .and_then(|guard| guard.expr()) | ||
625 | .map(|e| self.collect_expr(e)), | ||
620 | }) | 626 | }) |
621 | .collect() | 627 | .collect() |
622 | } else { | 628 | } else { |