aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/infer
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src/infer')
-rw-r--r--crates/ra_hir_ty/src/infer/path.rs25
1 files changed, 11 insertions, 14 deletions
diff --git a/crates/ra_hir_ty/src/infer/path.rs b/crates/ra_hir_ty/src/infer/path.rs
index 2c1d4831d..132f3d6f2 100644
--- a/crates/ra_hir_ty/src/infer/path.rs
+++ b/crates/ra_hir_ty/src/infer/path.rs
@@ -11,7 +11,7 @@ use hir_expand::name::Name;
11 11
12use crate::{db::HirDatabase, method_resolution, Substs, Ty, TypeWalk, ValueTyDefId}; 12use crate::{db::HirDatabase, method_resolution, Substs, Ty, TypeWalk, ValueTyDefId};
13 13
14use super::{ExprOrPatId, InferenceContext, TraitEnvironment, TraitRef}; 14use super::{ExprOrPatId, InferenceContext, TraitRef};
15 15
16impl<'a, D: HirDatabase> InferenceContext<'a, D> { 16impl<'a, D: HirDatabase> InferenceContext<'a, D> {
17 pub(super) fn infer_path( 17 pub(super) fn infer_path(
@@ -39,7 +39,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
39 } 39 }
40 let ty = self.make_ty(type_ref); 40 let ty = self.make_ty(type_ref);
41 let remaining_segments_for_ty = path.segments().take(path.segments().len() - 1); 41 let remaining_segments_for_ty = path.segments().take(path.segments().len() - 1);
42 let ty = Ty::from_type_relative_path(self.db, resolver, ty, remaining_segments_for_ty); 42 let ctx = crate::lower::TyLoweringContext { db: self.db, resolver: &resolver };
43 let ty = Ty::from_type_relative_path(&ctx, ty, remaining_segments_for_ty);
43 self.resolve_ty_assoc_item( 44 self.resolve_ty_assoc_item(
44 ty, 45 ty,
45 &path.segments().last().expect("path had at least one segment").name, 46 &path.segments().last().expect("path had at least one segment").name,
@@ -73,7 +74,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
73 if let Some(self_subst) = self_subst { 74 if let Some(self_subst) = self_subst {
74 ty = ty.subst(&self_subst); 75 ty = ty.subst(&self_subst);
75 } 76 }
76 let substs = Ty::substs_from_path(self.db, &self.resolver, path, typable); 77 let ctx = crate::lower::TyLoweringContext { db: self.db, resolver: &self.resolver };
78 let substs = Ty::substs_from_path(&ctx, path, typable);
77 let ty = ty.subst(&substs); 79 let ty = ty.subst(&substs);
78 Some(ty) 80 Some(ty)
79 } 81 }
@@ -98,13 +100,9 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
98 (TypeNs::TraitId(trait_), true) => { 100 (TypeNs::TraitId(trait_), true) => {
99 let segment = 101 let segment =
100 remaining_segments.last().expect("there should be at least one segment here"); 102 remaining_segments.last().expect("there should be at least one segment here");
101 let trait_ref = TraitRef::from_resolved_path( 103 let ctx = crate::lower::TyLoweringContext { db: self.db, resolver: &self.resolver };
102 self.db, 104 let trait_ref =
103 &self.resolver, 105 TraitRef::from_resolved_path(&ctx, trait_.into(), resolved_segment, None);
104 trait_.into(),
105 resolved_segment,
106 None,
107 );
108 self.resolve_trait_assoc_item(trait_ref, segment, id) 106 self.resolve_trait_assoc_item(trait_ref, segment, id)
109 } 107 }
110 (def, _) => { 108 (def, _) => {
@@ -114,9 +112,9 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
114 // as Iterator>::Item::default`) 112 // as Iterator>::Item::default`)
115 let remaining_segments_for_ty = 113 let remaining_segments_for_ty =
116 remaining_segments.take(remaining_segments.len() - 1); 114 remaining_segments.take(remaining_segments.len() - 1);
115 let ctx = crate::lower::TyLoweringContext { db: self.db, resolver: &self.resolver };
117 let ty = Ty::from_partly_resolved_hir_path( 116 let ty = Ty::from_partly_resolved_hir_path(
118 self.db, 117 &ctx,
119 &self.resolver,
120 def, 118 def,
121 resolved_segment, 119 resolved_segment,
122 remaining_segments_for_ty, 120 remaining_segments_for_ty,
@@ -193,14 +191,13 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
193 } 191 }
194 192
195 let canonical_ty = self.canonicalizer().canonicalize_ty(ty.clone()); 193 let canonical_ty = self.canonicalizer().canonicalize_ty(ty.clone());
196 let env = TraitEnvironment::lower(self.db, &self.resolver);
197 let krate = self.resolver.krate()?; 194 let krate = self.resolver.krate()?;
198 let traits_in_scope = self.resolver.traits_in_scope(self.db); 195 let traits_in_scope = self.resolver.traits_in_scope(self.db);
199 196
200 method_resolution::iterate_method_candidates( 197 method_resolution::iterate_method_candidates(
201 &canonical_ty.value, 198 &canonical_ty.value,
202 self.db, 199 self.db,
203 env, 200 self.trait_env.clone(),
204 krate, 201 krate,
205 &traits_in_scope, 202 &traits_in_scope,
206 Some(name), 203 Some(name),