diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index 603068ab53..f3cccca681 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs @@ -395,6 +395,10 @@ impl<'a> InferenceContext<'a> { } fn unify(&mut self, ty1: &Ty, ty2: &Ty) -> bool { + // TODO handle expectations properly + if ty2.is_unknown() { + return true; + } self.table.unify(ty1, ty2) } diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs index c82bda70f4..8467ea056d 100644 --- a/crates/hir_ty/src/infer/coerce.rs +++ b/crates/hir_ty/src/infer/coerce.rs @@ -19,6 +19,10 @@ impl<'a> InferenceContext<'a> { /// Unify two types, but may coerce the first one to the second one /// using "implicit coercion rules" if needed. pub(super) fn coerce(&mut self, from_ty: &Ty, to_ty: &Ty) -> bool { + // TODO handle expectations properly + if to_ty.is_unknown() { + return true; + } let from_ty = self.resolve_ty_shallow(from_ty).into_owned(); let to_ty = self.resolve_ty_shallow(to_ty); match self.coerce_inner(from_ty, &to_ty) {