aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-11-01 18:56:56 +0000
committerFlorian Diebold <[email protected]>2019-11-01 18:57:08 +0000
commitb29092ade31d7ff37532649dfbe1dc811edf3651 (patch)
tree98372e3e95ad410a70a4f685112b92951fec7dea
parentdc4066ebed57d43068035f574244e3abd18ee67f (diff)
Various review fixes
-rw-r--r--crates/ra_hir/src/ty.rs1
-rw-r--r--crates/ra_hir/src/ty/infer/path.rs18
-rw-r--r--crates/ra_hir/src/ty/method_resolution.rs11
3 files changed, 13 insertions, 17 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index e39f06e68..d1a9d7411 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -400,6 +400,7 @@ impl SubstsBuilder {
400 400
401 pub fn fill(mut self, filler: impl Iterator<Item = Ty>) -> Self { 401 pub fn fill(mut self, filler: impl Iterator<Item = Ty>) -> Self {
402 self.vec.extend(filler.take(self.remaining())); 402 self.vec.extend(filler.take(self.remaining()));
403 assert_eq!(self.remaining(), 0);
403 self 404 self
404 } 405 }
405 406
diff --git a/crates/ra_hir/src/ty/infer/path.rs b/crates/ra_hir/src/ty/infer/path.rs
index 1946bf608..59b7f7eb6 100644
--- a/crates/ra_hir/src/ty/infer/path.rs
+++ b/crates/ra_hir/src/ty/infer/path.rs
@@ -196,13 +196,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
196 AssocItem::Const(c) => ValueNs::Const(c), 196 AssocItem::Const(c) => ValueNs::Const(c),
197 AssocItem::TypeAlias(_) => unreachable!(), 197 AssocItem::TypeAlias(_) => unreachable!(),
198 }; 198 };
199 match item.container(self.db) { 199 let substs = match item.container(self.db) {
200 Container::ImplBlock(_) => { 200 Container::ImplBlock(_) => self.find_self_types(&def, ty.clone()),
201 let substs = self.find_self_types(&def, ty.clone());
202
203 self.write_assoc_resolution(id, item);
204 Some((def, substs))
205 }
206 Container::Trait(t) => { 201 Container::Trait(t) => {
207 // we're picking this method 202 // we're picking this method
208 let trait_substs = Substs::build_for_def(self.db, t) 203 let trait_substs = Substs::build_for_def(self.db, t)
@@ -217,11 +212,12 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
217 trait_: t, 212 trait_: t,
218 substs: trait_substs, 213 substs: trait_substs,
219 })); 214 }));
220 215 Some(substs)
221 self.write_assoc_resolution(id, item);
222 Some((def, Some(substs)))
223 } 216 }
224 } 217 };
218
219 self.write_assoc_resolution(id, item);
220 Some((def, substs))
225 }, 221 },
226 ) 222 )
227 } 223 }
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs
index 8d682bb18..8c3d32d09 100644
--- a/crates/ra_hir/src/ty/method_resolution.rs
+++ b/crates/ra_hir/src/ty/method_resolution.rs
@@ -166,12 +166,10 @@ pub(crate) fn lookup_method(
166 name: &Name, 166 name: &Name,
167 resolver: &Resolver, 167 resolver: &Resolver,
168) -> Option<(Ty, Function)> { 168) -> Option<(Ty, Function)> {
169 iterate_method_candidates(ty, db, resolver, Some(name), LookupMode::MethodCall, |ty, f| { 169 iterate_method_candidates(ty, db, resolver, Some(name), LookupMode::MethodCall, |ty, f| match f
170 if let AssocItem::Function(f) = f { 170 {
171 Some((ty.clone(), f)) 171 AssocItem::Function(f) => Some((ty.clone(), f)),
172 } else { 172 _ => None,
173 None
174 }
175 }) 173 })
176} 174}
177 175
@@ -189,6 +187,7 @@ pub enum LookupMode {
189 187
190// This would be nicer if it just returned an iterator, but that runs into 188// This would be nicer if it just returned an iterator, but that runs into
191// lifetime problems, because we need to borrow temp `CrateImplBlocks`. 189// lifetime problems, because we need to borrow temp `CrateImplBlocks`.
190// FIXME add a context type here?
192pub(crate) fn iterate_method_candidates<T>( 191pub(crate) fn iterate_method_candidates<T>(
193 ty: &Canonical<Ty>, 192 ty: &Canonical<Ty>,
194 db: &impl HirDatabase, 193 db: &impl HirDatabase,