) -> 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))
}
}
+ 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, .. } => {
if let Some(expected_ty) = expected_output.to_option(&mut self.table) {
self.table.fudge_inference(|table| {
if table.try_unify(&expected_ty, &output).is_ok() {
- table.resolve_with_fallback(inputs, |var, kind, _, _| match kind {
+ table.resolve_with_fallback(inputs, &|var, kind, _, _| match kind {
chalk_ir::VariableKind::Ty(tk) => var.to_ty(&Interner, tk).cast(&Interner),
chalk_ir::VariableKind::Lifetime => {
var.to_lifetime(&Interner).cast(&Interner)