From c256a72b039e849414245c563692feb41d1b051c Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Mon, 26 Aug 2019 20:41:31 +0200 Subject: Fix 'missing Ok in tail expr' validation Because of the coercion change, the type mismatch now only happens on the block expression. --- crates/ra_hir/src/expr/validation.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/expr/validation.rs b/crates/ra_hir/src/expr/validation.rs index 5d9d59ff8..c99c9c869 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> { 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); + self.validate_results_in_tail_expr(body.body_expr(), *t, db); } } @@ -97,8 +97,9 @@ impl<'a, 'b> ExprValidator<'a, 'b> { } } - fn validate_results_in_tail_expr(&mut self, id: ExprId, db: &impl HirDatabase) { - let mismatch = match self.infer.type_mismatch_for_expr(id) { + fn validate_results_in_tail_expr(&mut self, body_id: ExprId, id: ExprId, db: &impl HirDatabase) { + // the mismatch will be on the whole block currently + let mismatch = match self.infer.type_mismatch_for_expr(body_id) { Some(m) => m, None => return, }; -- cgit v1.2.3