aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir/src/expr/validation.rs14
1 files changed, 4 insertions, 10 deletions
diff --git a/crates/ra_hir/src/expr/validation.rs b/crates/ra_hir/src/expr/validation.rs
index f0da3d169..fce1c2f14 100644
--- a/crates/ra_hir/src/expr/validation.rs
+++ b/crates/ra_hir/src/expr/validation.rs
@@ -34,21 +34,15 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
34 pub(crate) fn validate_body(&mut self, db: &impl HirDatabase) { 34 pub(crate) fn validate_body(&mut self, db: &impl HirDatabase) {
35 let body = self.func.body(db); 35 let body = self.func.body(db);
36 36
37 // The final expr in the function body is the whole body,
38 // so the expression being returned is the penultimate expr.
39 let mut penultimate_expr = None;
40 let mut final_expr = None;
41
42 for e in body.exprs() { 37 for e in body.exprs() {
43 penultimate_expr = final_expr;
44 final_expr = Some(e);
45
46 if let (id, Expr::RecordLit { path, fields, spread }) = e { 38 if let (id, Expr::RecordLit { path, fields, spread }) = e {
47 self.validate_record_literal(id, path, fields, *spread, db); 39 self.validate_record_literal(id, path, fields, *spread, db);
48 } 40 }
49 } 41 }
50 if let Some(e) = penultimate_expr { 42
51 self.validate_results_in_tail_expr(e.0, db); 43 let body_expr = &body[body.body_expr()];
44 if let Expr::Block { statements: _, tail: Some(t) } = body_expr {
45 self.validate_results_in_tail_expr(*t, db);
52 } 46 }
53 } 47 }
54 48