diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-08-27 19:29:00 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-08-27 19:29:00 +0100 |
commit | 5a99184967c89992df4544d0c1ca27d79946a1a7 (patch) | |
tree | 1ffe483a008c2d43441d7f04ef0b006823faf5f0 /crates/ra_hir/src/expr/validation.rs | |
parent | 04c2961d0c5493962e948dc8101445cc76f1d460 (diff) | |
parent | 4adfdea1ad5aca393fa5bb9ff40fdc05827fcd56 (diff) |
Merge #1680
1680: Correctly infer match with early return r=flodiebold a=SomeoneToIgnore
Fixes #1505
Co-authored-by: Kirill Bulatov <[email protected]>
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/expr/validation.rs')
-rw-r--r-- | crates/ra_hir/src/expr/validation.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/crates/ra_hir/src/expr/validation.rs b/crates/ra_hir/src/expr/validation.rs index 5d9d59ff8..c8ae19869 100644 --- a/crates/ra_hir/src/expr/validation.rs +++ b/crates/ra_hir/src/expr/validation.rs | |||
@@ -41,7 +41,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
41 | 41 | ||
42 | let body_expr = &body[body.body_expr()]; | 42 | let body_expr = &body[body.body_expr()]; |
43 | if let Expr::Block { statements: _, tail: Some(t) } = body_expr { | 43 | if let Expr::Block { statements: _, tail: Some(t) } = body_expr { |
44 | self.validate_results_in_tail_expr(*t, db); | 44 | self.validate_results_in_tail_expr(body.body_expr(), *t, db); |
45 | } | 45 | } |
46 | } | 46 | } |
47 | 47 | ||
@@ -97,8 +97,14 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
100 | fn validate_results_in_tail_expr(&mut self, id: ExprId, db: &impl HirDatabase) { | 100 | fn validate_results_in_tail_expr( |
101 | let mismatch = match self.infer.type_mismatch_for_expr(id) { | 101 | &mut self, |
102 | body_id: ExprId, | ||
103 | id: ExprId, | ||
104 | db: &impl HirDatabase, | ||
105 | ) { | ||
106 | // the mismatch will be on the whole block currently | ||
107 | let mismatch = match self.infer.type_mismatch_for_expr(body_id) { | ||
102 | Some(m) => m, | 108 | Some(m) => m, |
103 | None => return, | 109 | None => return, |
104 | }; | 110 | }; |