mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
Various review fixes
This commit is contained in:
parent
dc4066ebed
commit
b29092ade3
3 changed files with 13 additions and 17 deletions
|
@ -400,6 +400,7 @@ impl SubstsBuilder {
|
||||||
|
|
||||||
pub fn fill(mut self, filler: impl Iterator<Item = Ty>) -> Self {
|
pub fn fill(mut self, filler: impl Iterator<Item = Ty>) -> Self {
|
||||||
self.vec.extend(filler.take(self.remaining()));
|
self.vec.extend(filler.take(self.remaining()));
|
||||||
|
assert_eq!(self.remaining(), 0);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,13 +196,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
||||||
AssocItem::Const(c) => ValueNs::Const(c),
|
AssocItem::Const(c) => ValueNs::Const(c),
|
||||||
AssocItem::TypeAlias(_) => unreachable!(),
|
AssocItem::TypeAlias(_) => unreachable!(),
|
||||||
};
|
};
|
||||||
match item.container(self.db) {
|
let substs = match item.container(self.db) {
|
||||||
Container::ImplBlock(_) => {
|
Container::ImplBlock(_) => self.find_self_types(&def, ty.clone()),
|
||||||
let substs = self.find_self_types(&def, ty.clone());
|
|
||||||
|
|
||||||
self.write_assoc_resolution(id, item);
|
|
||||||
Some((def, substs))
|
|
||||||
}
|
|
||||||
Container::Trait(t) => {
|
Container::Trait(t) => {
|
||||||
// we're picking this method
|
// we're picking this method
|
||||||
let trait_substs = Substs::build_for_def(self.db, t)
|
let trait_substs = Substs::build_for_def(self.db, t)
|
||||||
|
@ -217,11 +212,12 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
||||||
trait_: t,
|
trait_: t,
|
||||||
substs: trait_substs,
|
substs: trait_substs,
|
||||||
}));
|
}));
|
||||||
|
Some(substs)
|
||||||
self.write_assoc_resolution(id, item);
|
|
||||||
Some((def, Some(substs)))
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
self.write_assoc_resolution(id, item);
|
||||||
|
Some((def, substs))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,12 +166,10 @@ pub(crate) fn lookup_method(
|
||||||
name: &Name,
|
name: &Name,
|
||||||
resolver: &Resolver,
|
resolver: &Resolver,
|
||||||
) -> Option<(Ty, Function)> {
|
) -> Option<(Ty, Function)> {
|
||||||
iterate_method_candidates(ty, db, resolver, Some(name), LookupMode::MethodCall, |ty, f| {
|
iterate_method_candidates(ty, db, resolver, Some(name), LookupMode::MethodCall, |ty, f| match f
|
||||||
if let AssocItem::Function(f) = f {
|
{
|
||||||
Some((ty.clone(), f))
|
AssocItem::Function(f) => Some((ty.clone(), f)),
|
||||||
} else {
|
_ => None,
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,6 +187,7 @@ pub enum LookupMode {
|
||||||
|
|
||||||
// This would be nicer if it just returned an iterator, but that runs into
|
// This would be nicer if it just returned an iterator, but that runs into
|
||||||
// lifetime problems, because we need to borrow temp `CrateImplBlocks`.
|
// lifetime problems, because we need to borrow temp `CrateImplBlocks`.
|
||||||
|
// FIXME add a context type here?
|
||||||
pub(crate) fn iterate_method_candidates<T>(
|
pub(crate) fn iterate_method_candidates<T>(
|
||||||
ty: &Canonical<Ty>,
|
ty: &Canonical<Ty>,
|
||||||
db: &impl HirDatabase,
|
db: &impl HirDatabase,
|
||||||
|
|
Loading…
Reference in a new issue