diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir_ty/src/infer.rs | 4 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/coerce.rs | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index 603068ab5..f3cccca68 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs | |||
@@ -395,6 +395,10 @@ impl<'a> InferenceContext<'a> { | |||
395 | } | 395 | } |
396 | 396 | ||
397 | fn unify(&mut self, ty1: &Ty, ty2: &Ty) -> bool { | 397 | fn unify(&mut self, ty1: &Ty, ty2: &Ty) -> bool { |
398 | // TODO handle expectations properly | ||
399 | if ty2.is_unknown() { | ||
400 | return true; | ||
401 | } | ||
398 | self.table.unify(ty1, ty2) | 402 | self.table.unify(ty1, ty2) |
399 | } | 403 | } |
400 | 404 | ||
diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs index c82bda70f..8467ea056 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> { | |||
19 | /// Unify two types, but may coerce the first one to the second one | 19 | /// Unify two types, but may coerce the first one to the second one |
20 | /// using "implicit coercion rules" if needed. | 20 | /// using "implicit coercion rules" if needed. |
21 | pub(super) fn coerce(&mut self, from_ty: &Ty, to_ty: &Ty) -> bool { | 21 | pub(super) fn coerce(&mut self, from_ty: &Ty, to_ty: &Ty) -> bool { |
22 | // TODO handle expectations properly | ||
23 | if to_ty.is_unknown() { | ||
24 | return true; | ||
25 | } | ||
22 | let from_ty = self.resolve_ty_shallow(from_ty).into_owned(); | 26 | let from_ty = self.resolve_ty_shallow(from_ty).into_owned(); |
23 | let to_ty = self.resolve_ty_shallow(to_ty); | 27 | let to_ty = self.resolve_ty_shallow(to_ty); |
24 | match self.coerce_inner(from_ty, &to_ty) { | 28 | match self.coerce_inner(from_ty, &to_ty) { |