Fix 'missing Ok in tail expr' validation

Because of the coercion change, the type mismatch now only happens on the block
expression.
This commit is contained in:
Florian Diebold 2019-08-26 20:41:31 +02:00 committed by Kirill Bulatov
parent e37b6c5837
commit c256a72b03

View file

@ -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,
};