diff options
Diffstat (limited to 'crates/ra_hir/src/ty/infer')
-rw-r--r-- | crates/ra_hir/src/ty/infer/unify.rs | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/crates/ra_hir/src/ty/infer/unify.rs b/crates/ra_hir/src/ty/infer/unify.rs index 2ed326cd5..e7e8825d1 100644 --- a/crates/ra_hir/src/ty/infer/unify.rs +++ b/crates/ra_hir/src/ty/infer/unify.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | //! Unification and canonicalization logic. | 1 | //! Unification and canonicalization logic. |
2 | 2 | ||
3 | use super::InferenceContext; | 3 | use super::{InferenceContext, Obligation}; |
4 | use crate::db::HirDatabase; | 4 | use crate::db::HirDatabase; |
5 | use crate::ty::{ | 5 | use crate::ty::{ |
6 | Canonical, InEnvironment, InferTy, ProjectionPredicate, ProjectionTy, TraitRef, Ty, | 6 | Canonical, InEnvironment, InferTy, ProjectionPredicate, ProjectionTy, TraitRef, Ty, |
@@ -110,32 +110,24 @@ where | |||
110 | // FIXME: add some point, we need to introduce a `Fold` trait that abstracts | 110 | // FIXME: add some point, we need to introduce a `Fold` trait that abstracts |
111 | // over all the things that can be canonicalized (like Chalk and rustc have) | 111 | // over all the things that can be canonicalized (like Chalk and rustc have) |
112 | 112 | ||
113 | pub fn canonicalize_ty(mut self, ty: Ty) -> Canonicalized<Ty> { | 113 | pub(crate) fn canonicalize_ty(mut self, ty: Ty) -> Canonicalized<Ty> { |
114 | let result = self.do_canonicalize_ty(ty); | 114 | let result = self.do_canonicalize_ty(ty); |
115 | self.into_canonicalized(result) | 115 | self.into_canonicalized(result) |
116 | } | 116 | } |
117 | 117 | ||
118 | pub fn canonicalize_trait_ref( | 118 | pub(crate) fn canonicalize_obligation( |
119 | mut self, | 119 | mut self, |
120 | trait_ref_in_env: InEnvironment<TraitRef>, | 120 | obligation: InEnvironment<Obligation>, |
121 | ) -> Canonicalized<InEnvironment<TraitRef>> { | 121 | ) -> Canonicalized<InEnvironment<Obligation>> { |
122 | let result = self.do_canonicalize_trait_ref(trait_ref_in_env.value); | 122 | let result = match obligation.value { |
123 | // FIXME canonicalize env | 123 | Obligation::Trait(tr) => Obligation::Trait(self.do_canonicalize_trait_ref(tr)), |
124 | self.into_canonicalized(InEnvironment { | 124 | Obligation::Projection(pr) => { |
125 | value: result, | 125 | Obligation::Projection(self.do_canonicalize_projection_predicate(pr)) |
126 | environment: trait_ref_in_env.environment, | 126 | } |
127 | }) | 127 | }; |
128 | } | ||
129 | |||
130 | pub fn canonicalize_projection( | ||
131 | mut self, | ||
132 | projection: InEnvironment<ProjectionPredicate>, | ||
133 | ) -> Canonicalized<InEnvironment<ProjectionPredicate>> { | ||
134 | let result = self.do_canonicalize_projection_predicate(projection.value); | ||
135 | // FIXME canonicalize env | ||
136 | self.into_canonicalized(InEnvironment { | 128 | self.into_canonicalized(InEnvironment { |
137 | value: result, | 129 | value: result, |
138 | environment: projection.environment, | 130 | environment: obligation.environment, |
139 | }) | 131 | }) |
140 | } | 132 | } |
141 | } | 133 | } |