diff options
author | Lukas Wirth <[email protected]> | 2021-03-19 01:07:15 +0000 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-03-19 11:12:18 +0000 |
commit | 8996b1a2353539cb9c264d0effbde80567de6586 (patch) | |
tree | 4702a4384ee97782670c20e597c40e7da61b4fc2 /crates/hir_ty/src/infer | |
parent | 86878443b1789cac0e48177f5f2b95ad0d6e912c (diff) |
Replace Projection variant in GenericPredicate with AliasEq
Diffstat (limited to 'crates/hir_ty/src/infer')
-rw-r--r-- | crates/hir_ty/src/infer/unify.rs | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index f5ea09698..4738ec08a 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, FnPointer, GenericPredicate, InEnvironment, InferenceVar, | 10 | AliasEq, AliasTy, BoundVar, Canonical, DebruijnIndex, FnPointer, GenericPredicate, |
11 | Interner, Scalar, Substitution, Ty, TyKind, TypeWalk, | 11 | InEnvironment, InferenceVar, Interner, Scalar, Substitution, Ty, TyKind, TypeWalk, |
12 | }; | 12 | }; |
13 | 13 | ||
14 | impl<'a> InferenceContext<'a> { | 14 | impl<'a> InferenceContext<'a> { |
@@ -93,8 +93,8 @@ impl<'a, 'b> Canonicalizer<'a, 'b> { | |||
93 | Obligation::Trait(tr) => { | 93 | Obligation::Trait(tr) => { |
94 | Obligation::Trait(self.do_canonicalize(tr, DebruijnIndex::INNERMOST)) | 94 | Obligation::Trait(self.do_canonicalize(tr, DebruijnIndex::INNERMOST)) |
95 | } | 95 | } |
96 | Obligation::Projection(pr) => { | 96 | Obligation::AliasEq(alias_eq) => { |
97 | Obligation::Projection(self.do_canonicalize(pr, DebruijnIndex::INNERMOST)) | 97 | Obligation::AliasEq(self.do_canonicalize(alias_eq, DebruijnIndex::INNERMOST)) |
98 | } | 98 | } |
99 | }; | 99 | }; |
100 | self.into_canonicalized(InEnvironment { | 100 | self.into_canonicalized(InEnvironment { |
@@ -394,14 +394,25 @@ impl InferenceTable { | |||
394 | { | 394 | { |
395 | self.unify_substs(&tr1.substitution, &tr2.substitution, depth + 1) | 395 | self.unify_substs(&tr1.substitution, &tr2.substitution, depth + 1) |
396 | } | 396 | } |
397 | (GenericPredicate::Projection(proj1), GenericPredicate::Projection(proj2)) | 397 | ( |
398 | if proj1.projection_ty.associated_ty_id == proj2.projection_ty.associated_ty_id => | 398 | GenericPredicate::AliasEq(AliasEq { alias: alias1, ty: ty1 }), |
399 | { | 399 | GenericPredicate::AliasEq(AliasEq { alias: alias2, ty: ty2 }), |
400 | self.unify_substs( | 400 | ) => { |
401 | &proj1.projection_ty.substitution, | 401 | let (substitution1, substitution2) = match (alias1, alias2) { |
402 | &proj2.projection_ty.substitution, | 402 | (AliasTy::Projection(projection_ty1), AliasTy::Projection(projection_ty2)) |
403 | depth + 1, | 403 | if projection_ty1.associated_ty_id == projection_ty2.associated_ty_id => |
404 | ) && self.unify_inner(&proj1.ty, &proj2.ty, depth + 1) | 404 | { |
405 | (&projection_ty1.substitution, &projection_ty2.substitution) | ||
406 | } | ||
407 | (AliasTy::Opaque(opaque1), AliasTy::Opaque(opaque2)) | ||
408 | if opaque1.opaque_ty_id == opaque2.opaque_ty_id => | ||
409 | { | ||
410 | (&opaque1.substitution, &opaque2.substitution) | ||
411 | } | ||
412 | _ => return false, | ||
413 | }; | ||
414 | self.unify_substs(&substitution1, &substitution2, depth + 1) | ||
415 | && self.unify_inner(&ty1, &ty2, depth + 1) | ||
405 | } | 416 | } |
406 | _ => false, | 417 | _ => false, |
407 | } | 418 | } |