diff options
author | Phil Ellison <[email protected]> | 2019-08-12 20:21:29 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-08-25 10:56:23 +0100 |
commit | c8911e872eb46f811f645190e154b504fac157df (patch) | |
tree | d1153b9bdef618547aa27bedc81ffd92c165cda1 /crates/ra_hir/src/expr | |
parent | 4f6f3933ec04df55a39368d591c91cf81d980237 (diff) |
Remove reliance on expr ordering
Diffstat (limited to 'crates/ra_hir/src/expr')
-rw-r--r-- | crates/ra_hir/src/expr/validation.rs | 14 |
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 | ||