aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/infer/path.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-11-26 15:00:36 +0000
committerAleksey Kladov <[email protected]>2019-11-26 15:01:34 +0000
commit72d8e7e69abca9f27fb3ea386a6879324741e152 (patch)
tree55d2afdba12adaff0e7c329b6d0dfc79efb6db73 /crates/ra_hir/src/ty/infer/path.rs
parent6560e4ff2eae4e54384896d6ae100f1d2df20518 (diff)
Use TraitId in TraitRef
Diffstat (limited to 'crates/ra_hir/src/ty/infer/path.rs')
-rw-r--r--crates/ra_hir/src/ty/infer/path.rs39
1 files changed, 21 insertions, 18 deletions
diff --git a/crates/ra_hir/src/ty/infer/path.rs b/crates/ra_hir/src/ty/infer/path.rs
index 6165eba4f..202fff4f3 100644
--- a/crates/ra_hir/src/ty/infer/path.rs
+++ b/crates/ra_hir/src/ty/infer/path.rs
@@ -143,24 +143,27 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
143 id: ExprOrPatId, 143 id: ExprOrPatId,
144 ) -> Option<(ValueNs, Option<Substs>)> { 144 ) -> Option<(ValueNs, Option<Substs>)> {
145 let trait_ = trait_ref.trait_; 145 let trait_ = trait_ref.trait_;
146 let item = trait_.items(self.db).iter().copied().find_map(|item| match item { 146 let item =
147 AssocItem::Function(func) => { 147 self.db.trait_data(trait_).items.iter().map(|(_name, id)| (*id).into()).find_map(
148 if segment.name == func.name(self.db) { 148 |item| match item {
149 Some(AssocItem::Function(func)) 149 AssocItem::Function(func) => {
150 } else { 150 if segment.name == func.name(self.db) {
151 None 151 Some(AssocItem::Function(func))
152 } 152 } else {
153 } 153 None
154 }
155 }
154 156
155 AssocItem::Const(konst) => { 157 AssocItem::Const(konst) => {
156 if konst.name(self.db).map_or(false, |n| n == segment.name) { 158 if konst.name(self.db).map_or(false, |n| n == segment.name) {
157 Some(AssocItem::Const(konst)) 159 Some(AssocItem::Const(konst))
158 } else { 160 } else {
159 None 161 None
160 } 162 }
161 } 163 }
162 AssocItem::TypeAlias(_) => None, 164 AssocItem::TypeAlias(_) => None,
163 })?; 165 },
166 )?;
164 let def = match item { 167 let def = match item {
165 AssocItem::Function(f) => ValueNs::FunctionId(f.id), 168 AssocItem::Function(f) => ValueNs::FunctionId(f.id),
166 AssocItem::Const(c) => ValueNs::ConstId(c.id), 169 AssocItem::Const(c) => ValueNs::ConstId(c.id),
@@ -212,7 +215,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
212 .fill_with_params() 215 .fill_with_params()
213 .build(); 216 .build();
214 self.obligations.push(super::Obligation::Trait(TraitRef { 217 self.obligations.push(super::Obligation::Trait(TraitRef {
215 trait_: t, 218 trait_: t.id,
216 substs: trait_substs, 219 substs: trait_substs,
217 })); 220 }));
218 Some(substs) 221 Some(substs)