From c8911e872eb46f811f645190e154b504fac157df Mon Sep 17 00:00:00 2001 From: Phil Ellison Date: Mon, 12 Aug 2019 20:21:29 +0100 Subject: Remove reliance on expr ordering --- crates/ra_hir/src/expr/validation.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'crates/ra_hir/src/expr') 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> { pub(crate) fn validate_body(&mut self, db: &impl HirDatabase) { let body = self.func.body(db); - // The final expr in the function body is the whole body, - // so the expression being returned is the penultimate expr. - let mut penultimate_expr = None; - let mut final_expr = None; - for e in body.exprs() { - penultimate_expr = final_expr; - final_expr = Some(e); - if let (id, Expr::RecordLit { path, fields, spread }) = e { self.validate_record_literal(id, path, fields, *spread, db); } } - if let Some(e) = penultimate_expr { - self.validate_results_in_tail_expr(e.0, db); + + let body_expr = &body[body.body_expr()]; + if let Expr::Block { statements: _, tail: Some(t) } = body_expr { + self.validate_results_in_tail_expr(*t, db); } } -- cgit v1.2.3