Skip to content

Commit c6aea8c

Browse files
committed
Minor refactorings
1 parent 2feabc4 commit c6aea8c

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

crates/hir-ty/src/chalk_db.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -803,17 +803,17 @@ pub(crate) fn adt_variance_query(
803803
)
804804
}
805805

806+
/// Returns instantiated predicates.
806807
pub(super) fn convert_where_clauses(
807808
db: &dyn HirDatabase,
808809
def: GenericDefId,
809810
substs: &Substitution,
810811
) -> Vec<chalk_ir::QuantifiedWhereClause<Interner>> {
811-
let generic_predicates = db.generic_predicates(def);
812-
let mut result = Vec::with_capacity(generic_predicates.len());
813-
for pred in generic_predicates.iter() {
814-
result.push(pred.clone().substitute(Interner, substs));
815-
}
816-
result
812+
db.generic_predicates(def)
813+
.iter()
814+
.cloned()
815+
.map(|pred| pred.substitute(Interner, substs))
816+
.collect()
817817
}
818818

819819
pub(super) fn generic_predicate_to_inline_bound(

crates/hir-ty/src/method_resolution.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -742,9 +742,8 @@ fn find_matching_impl(
742742
actual_trait_ref: TraitRef,
743743
) -> Option<(Arc<ImplData>, Substitution)> {
744744
let db = table.db;
745-
loop {
746-
let impl_ = impls.next()?;
747-
let r = table.run_in_snapshot(|table| {
745+
impls.find_map(|impl_| {
746+
table.run_in_snapshot(|table| {
748747
let impl_data = db.impl_data(impl_);
749748
let impl_substs =
750749
TyBuilder::subst_for_def(db, impl_, None).fill_with_inference_vars(table).build();
@@ -762,11 +761,8 @@ fn find_matching_impl(
762761
.map(|b| b.cast(Interner));
763762
let goal = crate::Goal::all(Interner, wcs);
764763
table.try_obligation(goal).map(|_| (impl_data, table.resolve_completely(impl_substs)))
765-
});
766-
if r.is_some() {
767-
break r;
768-
}
769-
}
764+
})
765+
})
770766
}
771767

772768
fn is_inherent_impl_coherent(

0 commit comments

Comments
 (0)