diff options
Diffstat (limited to 'crates/ra_hir/src/ty/infer/path.rs')
-rw-r--r-- | crates/ra_hir/src/ty/infer/path.rs | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/crates/ra_hir/src/ty/infer/path.rs b/crates/ra_hir/src/ty/infer/path.rs index 6165eba4f..be2067dd4 100644 --- a/crates/ra_hir/src/ty/infer/path.rs +++ b/crates/ra_hir/src/ty/infer/path.rs | |||
@@ -7,7 +7,7 @@ use hir_def::{ | |||
7 | 7 | ||
8 | use crate::{ | 8 | use crate::{ |
9 | db::HirDatabase, | 9 | db::HirDatabase, |
10 | ty::{method_resolution, Namespace, Substs, Ty, TypableDef, TypeWalk}, | 10 | ty::{method_resolution, Substs, Ty, TypeWalk, ValueTyDefId}, |
11 | AssocItem, Container, Function, Name, Path, | 11 | AssocItem, Container, Function, Name, Path, |
12 | }; | 12 | }; |
13 | 13 | ||
@@ -56,7 +56,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
56 | } | 56 | } |
57 | }; | 57 | }; |
58 | 58 | ||
59 | let typable: TypableDef = match value { | 59 | let typable: ValueTyDefId = match value { |
60 | ValueNs::LocalBinding(pat) => { | 60 | ValueNs::LocalBinding(pat) => { |
61 | let ty = self.result.type_of_pat.get(pat)?.clone(); | 61 | let ty = self.result.type_of_pat.get(pat)?.clone(); |
62 | let ty = self.resolve_ty_as_possible(&mut vec![], ty); | 62 | let ty = self.resolve_ty_as_possible(&mut vec![], ty); |
@@ -69,11 +69,10 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
69 | ValueNs::EnumVariantId(it) => it.into(), | 69 | ValueNs::EnumVariantId(it) => it.into(), |
70 | }; | 70 | }; |
71 | 71 | ||
72 | let mut ty = self.db.type_for_def(typable, Namespace::Values); | 72 | let mut ty = self.db.value_ty(typable); |
73 | if let Some(self_subst) = self_subst { | 73 | if let Some(self_subst) = self_subst { |
74 | ty = ty.subst(&self_subst); | 74 | ty = ty.subst(&self_subst); |
75 | } | 75 | } |
76 | |||
77 | let substs = Ty::substs_from_path(self.db, &self.resolver, path, typable); | 76 | let substs = Ty::substs_from_path(self.db, &self.resolver, path, typable); |
78 | let ty = ty.subst(&substs); | 77 | let ty = ty.subst(&substs); |
79 | Some(ty) | 78 | Some(ty) |
@@ -143,24 +142,27 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
143 | id: ExprOrPatId, | 142 | id: ExprOrPatId, |
144 | ) -> Option<(ValueNs, Option<Substs>)> { | 143 | ) -> Option<(ValueNs, Option<Substs>)> { |
145 | let trait_ = trait_ref.trait_; | 144 | let trait_ = trait_ref.trait_; |
146 | let item = trait_.items(self.db).iter().copied().find_map(|item| match item { | 145 | let item = |
147 | AssocItem::Function(func) => { | 146 | self.db.trait_data(trait_).items.iter().map(|(_name, id)| (*id).into()).find_map( |
148 | if segment.name == func.name(self.db) { | 147 | |item| match item { |
149 | Some(AssocItem::Function(func)) | 148 | AssocItem::Function(func) => { |
150 | } else { | 149 | if segment.name == func.name(self.db) { |
151 | None | 150 | Some(AssocItem::Function(func)) |
152 | } | 151 | } else { |
153 | } | 152 | None |
153 | } | ||
154 | } | ||
154 | 155 | ||
155 | AssocItem::Const(konst) => { | 156 | AssocItem::Const(konst) => { |
156 | if konst.name(self.db).map_or(false, |n| n == segment.name) { | 157 | if konst.name(self.db).map_or(false, |n| n == segment.name) { |
157 | Some(AssocItem::Const(konst)) | 158 | Some(AssocItem::Const(konst)) |
158 | } else { | 159 | } else { |
159 | None | 160 | None |
160 | } | 161 | } |
161 | } | 162 | } |
162 | AssocItem::TypeAlias(_) => None, | 163 | AssocItem::TypeAlias(_) => None, |
163 | })?; | 164 | }, |
165 | )?; | ||
164 | let def = match item { | 166 | let def = match item { |
165 | AssocItem::Function(f) => ValueNs::FunctionId(f.id), | 167 | AssocItem::Function(f) => ValueNs::FunctionId(f.id), |
166 | AssocItem::Const(c) => ValueNs::ConstId(c.id), | 168 | AssocItem::Const(c) => ValueNs::ConstId(c.id), |
@@ -212,7 +214,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
212 | .fill_with_params() | 214 | .fill_with_params() |
213 | .build(); | 215 | .build(); |
214 | self.obligations.push(super::Obligation::Trait(TraitRef { | 216 | self.obligations.push(super::Obligation::Trait(TraitRef { |
215 | trait_: t, | 217 | trait_: t.id, |
216 | substs: trait_substs, | 218 | substs: trait_substs, |
217 | })); | 219 | })); |
218 | Some(substs) | 220 | Some(substs) |