Various review fixes

This commit is contained in:
Florian Diebold 2019-11-01 19:56:56 +01:00
parent dc4066ebed
commit b29092ade3
3 changed files with 13 additions and 17 deletions

View file

@ -400,6 +400,7 @@ impl SubstsBuilder {
pub fn fill(mut self, filler: impl Iterator<Item = Ty>) -> Self {
self.vec.extend(filler.take(self.remaining()));
assert_eq!(self.remaining(), 0);
self
}

View file

@ -196,13 +196,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
AssocItem::Const(c) => ValueNs::Const(c),
AssocItem::TypeAlias(_) => unreachable!(),
};
match item.container(self.db) {
Container::ImplBlock(_) => {
let substs = self.find_self_types(&def, ty.clone());
self.write_assoc_resolution(id, item);
Some((def, substs))
}
let substs = match item.container(self.db) {
Container::ImplBlock(_) => self.find_self_types(&def, ty.clone()),
Container::Trait(t) => {
// we're picking this method
let trait_substs = Substs::build_for_def(self.db, t)
@ -217,11 +212,12 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
trait_: t,
substs: trait_substs,
}));
self.write_assoc_resolution(id, item);
Some((def, Some(substs)))
Some(substs)
}
}
};
self.write_assoc_resolution(id, item);
Some((def, substs))
},
)
}

View file

@ -166,12 +166,10 @@ pub(crate) fn lookup_method(
name: &Name,
resolver: &Resolver,
) -> Option<(Ty, Function)> {
iterate_method_candidates(ty, db, resolver, Some(name), LookupMode::MethodCall, |ty, f| {
if let AssocItem::Function(f) = f {
Some((ty.clone(), f))
} else {
None
}
iterate_method_candidates(ty, db, resolver, Some(name), LookupMode::MethodCall, |ty, f| match f
{
AssocItem::Function(f) => Some((ty.clone(), f)),
_ => None,
})
}
@ -189,6 +187,7 @@ pub enum LookupMode {
// This would be nicer if it just returned an iterator, but that runs into
// lifetime problems, because we need to borrow temp `CrateImplBlocks`.
// FIXME add a context type here?
pub(crate) fn iterate_method_candidates<T>(
ty: &Canonical<Ty>,
db: &impl HirDatabase,