diff options
Diffstat (limited to 'crates/hir_ty/src/infer.rs')
-rw-r--r-- | crates/hir_ty/src/infer.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index 2610c9279..82186979a 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs | |||
@@ -37,12 +37,12 @@ use stdx::impl_from; | |||
37 | use syntax::SmolStr; | 37 | use syntax::SmolStr; |
38 | 38 | ||
39 | use super::{ | 39 | use super::{ |
40 | traits::{Guidance, Obligation, ProjectionPredicate, Solution}, | 40 | traits::{Guidance, Obligation, Solution}, |
41 | InEnvironment, ProjectionTy, Substitution, TraitEnvironment, TraitRef, Ty, TypeWalk, | 41 | InEnvironment, ProjectionTy, Substitution, TraitEnvironment, TraitRef, Ty, TypeWalk, |
42 | }; | 42 | }; |
43 | use crate::{ | 43 | use crate::{ |
44 | db::HirDatabase, infer::diagnostics::InferenceDiagnostic, lower::ImplTraitLoweringMode, | 44 | db::HirDatabase, infer::diagnostics::InferenceDiagnostic, lower::ImplTraitLoweringMode, |
45 | to_assoc_type_id, AliasTy, Interner, TyKind, | 45 | to_assoc_type_id, to_chalk_trait_id, AliasEq, AliasTy, Interner, TyKind, |
46 | }; | 46 | }; |
47 | 47 | ||
48 | pub(crate) use unify::unify; | 48 | pub(crate) use unify::unify; |
@@ -394,16 +394,17 @@ impl<'a> InferenceContext<'a> { | |||
394 | .push(inner_ty) | 394 | .push(inner_ty) |
395 | .fill(params.iter().cloned()) | 395 | .fill(params.iter().cloned()) |
396 | .build(); | 396 | .build(); |
397 | let trait_ref = TraitRef { trait_, substs: substs.clone() }; | 397 | let trait_ref = |
398 | let projection = ProjectionPredicate { | 398 | TraitRef { trait_id: to_chalk_trait_id(trait_), substitution: substs.clone() }; |
399 | ty: ty.clone(), | 399 | let alias_eq = AliasEq { |
400 | projection_ty: ProjectionTy { | 400 | alias: AliasTy::Projection(ProjectionTy { |
401 | associated_ty_id: to_assoc_type_id(res_assoc_ty), | 401 | associated_ty_id: to_assoc_type_id(res_assoc_ty), |
402 | substitution: substs, | 402 | substitution: substs, |
403 | }, | 403 | }), |
404 | ty: ty.clone(), | ||
404 | }; | 405 | }; |
405 | self.obligations.push(Obligation::Trait(trait_ref)); | 406 | self.obligations.push(Obligation::Trait(trait_ref)); |
406 | self.obligations.push(Obligation::Projection(projection)); | 407 | self.obligations.push(Obligation::AliasEq(alias_eq)); |
407 | self.resolve_ty_as_possible(ty) | 408 | self.resolve_ty_as_possible(ty) |
408 | } | 409 | } |
409 | None => self.err_ty(), | 410 | None => self.err_ty(), |
@@ -428,8 +429,8 @@ impl<'a> InferenceContext<'a> { | |||
428 | 429 | ||
429 | fn normalize_projection_ty(&mut self, proj_ty: ProjectionTy) -> Ty { | 430 | fn normalize_projection_ty(&mut self, proj_ty: ProjectionTy) -> Ty { |
430 | let var = self.table.new_type_var(); | 431 | let var = self.table.new_type_var(); |
431 | let predicate = ProjectionPredicate { projection_ty: proj_ty, ty: var.clone() }; | 432 | let alias_eq = AliasEq { alias: AliasTy::Projection(proj_ty), ty: var.clone() }; |
432 | let obligation = Obligation::Projection(predicate); | 433 | let obligation = Obligation::AliasEq(alias_eq); |
433 | self.obligations.push(obligation); | 434 | self.obligations.push(obligation); |
434 | var | 435 | var |
435 | } | 436 | } |