Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir_ty/src/infer/expr.rs')
-rw-r--r--crates/hir_ty/src/infer/expr.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs
index f5bc898a85..ada5717f1a 100644
--- a/crates/hir_ty/src/infer/expr.rs
+++ b/crates/hir_ty/src/infer/expr.rs
@@ -914,7 +914,7 @@ impl<'a> InferenceContext<'a> {
) -> Ty {
for stmt in statements {
match stmt {
- Statement::Let { pat, type_ref, initializer } => {
+ Statement::Let { pat, type_ref, initializer, else_branch } => {
let decl_ty = type_ref
.as_ref()
.map(|tr| self.make_ty(tr))
@@ -931,6 +931,13 @@ impl<'a> InferenceContext<'a> {
}
}
+ if let Some(expr) = else_branch {
+ self.infer_expr_coerce(
+ *expr,
+ &Expectation::has_type(Ty::new(&Interner, TyKind::Never)),
+ );
+ }
+
self.infer_pat(*pat, &ty, BindingMode::default());
}
Statement::Expr { expr, .. } => {