diff options
Diffstat (limited to 'crates/hir_ty/src/infer/unify.rs')
-rw-r--r-- | crates/hir_ty/src/infer/unify.rs | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index 2501a4e0a..66f8fe8a3 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs | |||
@@ -7,8 +7,8 @@ use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue}; | |||
7 | 7 | ||
8 | use super::{InferenceContext, Obligation}; | 8 | use super::{InferenceContext, Obligation}; |
9 | use crate::{ | 9 | use crate::{ |
10 | BoundVar, Canonical, DebruijnIndex, GenericPredicate, InEnvironment, InferenceVar, Interner, | 10 | BoundVar, Canonical, DebruijnIndex, FnPointer, GenericPredicate, InEnvironment, InferenceVar, |
11 | Scalar, Substs, Ty, TyKind, TypeWalk, | 11 | Interner, Scalar, Substs, Ty, TyKind, TypeWalk, |
12 | }; | 12 | }; |
13 | 13 | ||
14 | impl<'a> InferenceContext<'a> { | 14 | impl<'a> InferenceContext<'a> { |
@@ -283,9 +283,23 @@ impl InferenceTable { | |||
283 | let ty1 = self.resolve_ty_shallow(ty1); | 283 | let ty1 = self.resolve_ty_shallow(ty1); |
284 | let ty2 = self.resolve_ty_shallow(ty2); | 284 | let ty2 = self.resolve_ty_shallow(ty2); |
285 | if ty1.equals_ctor(&ty2) { | 285 | if ty1.equals_ctor(&ty2) { |
286 | match (ty1.substs(), ty2.substs()) { | 286 | match (ty1.interned(&Interner), ty2.interned(&Interner)) { |
287 | (Some(st1), Some(st2)) => self.unify_substs(st1, st2, depth + 1), | 287 | (TyKind::Adt(_, substs1), TyKind::Adt(_, substs2)) |
288 | (None, None) => true, | 288 | | (TyKind::FnDef(_, substs1), TyKind::FnDef(_, substs2)) |
289 | | ( | ||
290 | TyKind::Function(FnPointer { substs: substs1, .. }), | ||
291 | TyKind::Function(FnPointer { substs: substs2, .. }), | ||
292 | ) | ||
293 | | (TyKind::Tuple(_, substs1), TyKind::Tuple(_, substs2)) | ||
294 | | (TyKind::OpaqueType(_, substs1), TyKind::OpaqueType(_, substs2)) | ||
295 | | (TyKind::AssociatedType(_, substs1), TyKind::AssociatedType(_, substs2)) | ||
296 | | (TyKind::Closure(.., substs1), TyKind::Closure(.., substs2)) => { | ||
297 | self.unify_substs(substs1, substs2, depth + 1) | ||
298 | } | ||
299 | (TyKind::Ref(_, ty1), TyKind::Ref(_, ty2)) | ||
300 | | (TyKind::Raw(_, ty1), TyKind::Raw(_, ty2)) | ||
301 | | (TyKind::Array(ty1), TyKind::Array(ty2)) | ||
302 | | (TyKind::Slice(ty1), TyKind::Slice(ty2)) => self.unify_inner(ty1, ty2, depth + 1), | ||
289 | _ => false, | 303 | _ => false, |
290 | } | 304 | } |
291 | } else { | 305 | } else { |