aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/infer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty/infer.rs')
-rw-r--r--crates/ra_hir/src/ty/infer.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index 594c5bc79..74fc77cfb 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -245,7 +245,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
245 &self.resolver, 245 &self.resolver,
246 type_ref, 246 type_ref,
247 ); 247 );
248 self.insert_type_vars(ty) 248 let ty = self.insert_type_vars(ty);
249 self.normalize_associated_types_in(ty)
249 } 250 }
250 251
251 fn unify_substs(&mut self, substs1: &Substs, substs2: &Substs, depth: usize) -> bool { 252 fn unify_substs(&mut self, substs1: &Substs, substs2: &Substs, depth: usize) -> bool {
@@ -411,6 +412,25 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
411 ty 412 ty
412 } 413 }
413 414
415 fn normalize_associated_types_in(&mut self, ty: Ty) -> Ty {
416 ty.fold(&mut |ty| match ty {
417 Ty::Projection(proj_ty) => self.normalize_projection_ty(proj_ty),
418 Ty::UnselectedProjection(proj_ty) => {
419 // FIXME
420 Ty::UnselectedProjection(proj_ty)
421 }
422 _ => ty,
423 })
424 }
425
426 fn normalize_projection_ty(&mut self, proj_ty: ProjectionTy) -> Ty {
427 let var = self.new_type_var();
428 let predicate = ProjectionPredicate { projection_ty: proj_ty.clone(), ty: var.clone() };
429 let obligation = Obligation::Projection(predicate);
430 self.obligations.push(obligation);
431 var
432 }
433
414 /// Resolves the type completely; type variables without known type are 434 /// Resolves the type completely; type variables without known type are
415 /// replaced by Ty::Unknown. 435 /// replaced by Ty::Unknown.
416 fn resolve_ty_completely(&mut self, tv_stack: &mut Vec<TypeVarId>, ty: Ty) -> Ty { 436 fn resolve_ty_completely(&mut self, tv_stack: &mut Vec<TypeVarId>, ty: Ty) -> Ty {