Fix inference with conditionally compiled tails

Fixes #8378
This commit is contained in:
Daniel McNab 2021-04-07 12:45:17 +01:00
parent eb741e895f
commit ebbcf9f458
5 changed files with 21 additions and 11 deletions

View file

@ -83,7 +83,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
if let Expr::Block { statements, tail, .. } = body_expr {
if let Some(t) = tail {
self.validate_results_in_tail_expr(body.body_expr, *t, db);
} else if let Some(Statement::Expr(id)) = statements.last() {
} else if let Some(Statement::Expr { expr: id, .. }) = statements.last() {
self.validate_missing_tail_expr(body.body_expr, *id, db);
}
}

View file

@ -809,7 +809,7 @@ impl<'a> InferenceContext<'a> {
let ty = self.resolve_ty_as_possible(ty);
self.infer_pat(*pat, &ty, BindingMode::default());
}
Statement::Expr(expr) => {
Statement::Expr { expr, .. } => {
self.infer_expr(*expr, &Expectation::none());
}
}