aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/infer
diff options
context:
space:
mode:
authorUnreal Hoang <[email protected]>2019-07-07 08:31:09 +0100
committerUnreal Hoang <[email protected]>2019-07-07 14:26:51 +0100
commitf7cd40d8306dfd3f2c55ad97de5167319350a592 (patch)
tree73d1da8789a0a6109805768d7f2cad3336d3453b /crates/ra_hir/src/ty/infer
parentfee552d4873b1cce4e622c7eb2f0189b276b01be (diff)
add projection to infer for loop variable
Diffstat (limited to 'crates/ra_hir/src/ty/infer')
-rw-r--r--crates/ra_hir/src/ty/infer/unify.rs29
1 files changed, 28 insertions, 1 deletions
diff --git a/crates/ra_hir/src/ty/infer/unify.rs b/crates/ra_hir/src/ty/infer/unify.rs
index 49bf5b946..a24e5eb5c 100644
--- a/crates/ra_hir/src/ty/infer/unify.rs
+++ b/crates/ra_hir/src/ty/infer/unify.rs
@@ -2,7 +2,7 @@
2 2
3use super::InferenceContext; 3use super::InferenceContext;
4use crate::db::HirDatabase; 4use crate::db::HirDatabase;
5use crate::ty::{Canonical, InferTy, TraitRef, Ty}; 5use crate::ty::{Canonical, InferTy, ProjectionPredicate, ProjectionTy, TraitRef, Ty};
6 6
7impl<'a, D: HirDatabase> InferenceContext<'a, D> { 7impl<'a, D: HirDatabase> InferenceContext<'a, D> {
8 pub(super) fn canonicalizer<'b>(&'b mut self) -> Canonicalizer<'a, 'b, D> 8 pub(super) fn canonicalizer<'b>(&'b mut self) -> Canonicalizer<'a, 'b, D>
@@ -86,6 +86,25 @@ where
86 } 86 }
87 } 87 }
88 88
89 fn do_canonicalize_projection_ty(&mut self, projection_ty: ProjectionTy) -> ProjectionTy {
90 let params = projection_ty
91 .parameters
92 .iter()
93 .map(|ty| self.do_canonicalize_ty(ty.clone()))
94 .collect::<Vec<_>>();
95 ProjectionTy { associated_ty: projection_ty.associated_ty, parameters: params.into() }
96 }
97
98 fn do_canonicalize_projection_predicate(
99 &mut self,
100 projection: ProjectionPredicate,
101 ) -> ProjectionPredicate {
102 let ty = self.do_canonicalize_ty(projection.ty);
103 let projection_ty = self.do_canonicalize_projection_ty(projection.projection_ty);
104
105 ProjectionPredicate { ty, projection_ty }
106 }
107
89 pub fn canonicalize_ty(mut self, ty: Ty) -> Canonicalized<Ty> { 108 pub fn canonicalize_ty(mut self, ty: Ty) -> Canonicalized<Ty> {
90 let result = self.do_canonicalize_ty(ty); 109 let result = self.do_canonicalize_ty(ty);
91 self.into_canonicalized(result) 110 self.into_canonicalized(result)
@@ -95,6 +114,14 @@ where
95 let result = self.do_canonicalize_trait_ref(trait_ref); 114 let result = self.do_canonicalize_trait_ref(trait_ref);
96 self.into_canonicalized(result) 115 self.into_canonicalized(result)
97 } 116 }
117
118 pub fn canonicalize_projection(
119 mut self,
120 projection: ProjectionPredicate,
121 ) -> Canonicalized<ProjectionPredicate> {
122 let result = self.do_canonicalize_projection_predicate(projection);
123 self.into_canonicalized(result)
124 }
98} 125}
99 126
100impl<T> Canonicalized<T> { 127impl<T> Canonicalized<T> {