1
Fork 0

Switch from for-loop to filter_map

This commit is contained in:
León Orell Valerian Liehr 2023-02-17 16:55:07 +01:00
parent b5e73bfe90
commit 3dc38fbc91
No known key found for this signature in database
GPG key ID: D17A07215F68E713

View file

@ -2232,9 +2232,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let param_env = tcx.param_env(block.owner.to_def_id());
let cause = ObligationCause::misc(span, block.owner.def_id);
let mut fulfillment_errors = Vec::new();
let mut applicable_candidates = Vec::new();
for &(impl_, (assoc_item, def_scope)) in &candidates {
let mut applicable_candidates: Vec<_> = candidates
.iter()
.filter_map(|&(impl_, (assoc_item, def_scope))| {
let ocx = ObligationCtxt::new(&infcx);
let impl_ty = tcx.type_of(impl_);
@ -2244,9 +2244,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
// Check that the Self-types can be related.
// FIXME(fmease): Should we use `eq` here?
if ocx.sup(&ObligationCause::dummy(), param_env, impl_ty, self_ty).is_err() {
continue;
}
ocx.sup(&ObligationCause::dummy(), param_env, impl_ty, self_ty).ok()?;
// Check whether the impl imposes obligations we have to worry about.
let impl_bounds = tcx.predicates_of(impl_);
@ -2262,11 +2260,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let errors = ocx.select_where_possible();
if !errors.is_empty() {
fulfillment_errors = errors;
continue;
return None;
}
applicable_candidates.push((assoc_item, def_scope));
}
Some((assoc_item, def_scope))
})
.collect();
if applicable_candidates.len() > 1 {
return Err(self.complain_about_ambiguous_inherent_assoc_type(