Rollup merge of #126471 - oli-obk:filter_loop, r=compiler-errors
Use a consistent way to filter out bounds instead of splitting it into three places just a small cleanup, no logic change. Initially the code had me looking for why anything was special here, only to realize there's nothing interesting going on
This commit is contained in:
commit
6f21da3bb4
@ -239,24 +239,19 @@ fn assemble_candidates_from_caller_bounds<'o>(
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let all_bounds = stack
|
let bounds = stack
|
||||||
.obligation
|
.obligation
|
||||||
.param_env
|
.param_env
|
||||||
.caller_bounds()
|
.caller_bounds()
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|p| !p.references_error())
|
.filter(|p| !p.references_error())
|
||||||
.filter_map(|p| p.as_trait_clause());
|
.filter_map(|p| p.as_trait_clause())
|
||||||
|
|
||||||
// Micro-optimization: filter out predicates relating to different traits.
|
// Micro-optimization: filter out predicates relating to different traits.
|
||||||
let matching_bounds =
|
.filter(|p| p.def_id() == stack.obligation.predicate.def_id())
|
||||||
all_bounds.filter(|p| p.def_id() == stack.obligation.predicate.def_id());
|
.filter(|p| p.polarity() == stack.obligation.predicate.polarity());
|
||||||
|
|
||||||
// Keep only those bounds which may apply, and propagate overflow if it occurs.
|
// Keep only those bounds which may apply, and propagate overflow if it occurs.
|
||||||
for bound in matching_bounds {
|
for bound in bounds {
|
||||||
if bound.skip_binder().polarity != stack.obligation.predicate.skip_binder().polarity {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME(oli-obk): it is suspicious that we are dropping the constness and
|
// FIXME(oli-obk): it is suspicious that we are dropping the constness and
|
||||||
// polarity here.
|
// polarity here.
|
||||||
let wc = self.where_clause_may_apply(stack, bound.map_bound(|t| t.trait_ref))?;
|
let wc = self.where_clause_may_apply(stack, bound.map_bound(|t| t.trait_ref))?;
|
||||||
|
Loading…
Reference in New Issue
Block a user