diff options
Diffstat (limited to 'crates/hir_ty/src/autoderef.rs')
-rw-r--r-- | crates/hir_ty/src/autoderef.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/crates/hir_ty/src/autoderef.rs b/crates/hir_ty/src/autoderef.rs index bd2ff5d38..33b966026 100644 --- a/crates/hir_ty/src/autoderef.rs +++ b/crates/hir_ty/src/autoderef.rs | |||
@@ -12,10 +12,11 @@ use log::{info, warn}; | |||
12 | 12 | ||
13 | use crate::{ | 13 | use crate::{ |
14 | db::HirDatabase, | 14 | db::HirDatabase, |
15 | to_assoc_type_id, | 15 | to_assoc_type_id, to_chalk_trait_id, |
16 | traits::{InEnvironment, Solution}, | 16 | traits::{InEnvironment, Solution}, |
17 | utils::generics, | 17 | utils::generics, |
18 | BoundVar, Canonical, DebruijnIndex, Interner, Obligation, Substitution, TraitRef, Ty, TyKind, | 18 | AliasEq, AliasTy, BoundVar, Canonical, DebruijnIndex, Interner, Obligation, ProjectionTy, |
19 | Substitution, TraitRef, Ty, TyKind, | ||
19 | }; | 20 | }; |
20 | 21 | ||
21 | const AUTODEREF_RECURSION_LIMIT: usize = 10; | 22 | const AUTODEREF_RECURSION_LIMIT: usize = 10; |
@@ -68,7 +69,8 @@ fn deref_by_trait( | |||
68 | Substitution::build_for_generics(&generic_params).push(ty.value.value.clone()).build(); | 69 | Substitution::build_for_generics(&generic_params).push(ty.value.value.clone()).build(); |
69 | 70 | ||
70 | // Check that the type implements Deref at all | 71 | // Check that the type implements Deref at all |
71 | let trait_ref = TraitRef { trait_: deref_trait, substs: parameters.clone() }; | 72 | let trait_ref = |
73 | TraitRef { trait_id: to_chalk_trait_id(deref_trait), substitution: parameters.clone() }; | ||
72 | let implements_goal = Canonical { | 74 | let implements_goal = Canonical { |
73 | kinds: ty.value.kinds.clone(), | 75 | kinds: ty.value.kinds.clone(), |
74 | value: InEnvironment { | 76 | value: InEnvironment { |
@@ -81,16 +83,16 @@ fn deref_by_trait( | |||
81 | } | 83 | } |
82 | 84 | ||
83 | // Now do the assoc type projection | 85 | // Now do the assoc type projection |
84 | let projection = super::traits::ProjectionPredicate { | 86 | let projection = AliasEq { |
85 | ty: TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, ty.value.kinds.len())) | 87 | alias: AliasTy::Projection(ProjectionTy { |
86 | .intern(&Interner), | ||
87 | projection_ty: super::ProjectionTy { | ||
88 | associated_ty_id: to_assoc_type_id(target), | 88 | associated_ty_id: to_assoc_type_id(target), |
89 | substitution: parameters, | 89 | substitution: parameters, |
90 | }, | 90 | }), |
91 | ty: TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, ty.value.kinds.len())) | ||
92 | .intern(&Interner), | ||
91 | }; | 93 | }; |
92 | 94 | ||
93 | let obligation = super::Obligation::Projection(projection); | 95 | let obligation = super::Obligation::AliasEq(projection); |
94 | 96 | ||
95 | let in_env = InEnvironment { value: obligation, environment: ty.environment }; | 97 | let in_env = InEnvironment { value: obligation, environment: ty.environment }; |
96 | 98 | ||