Skip to content

Commit

Permalink
Unrolled build for rust-lang#126471
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#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
  • Loading branch information
rust-timer authored Jun 15, 2024
2 parents 1d1356d + 5c8bb67 commit 6bfc340
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,24 +239,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
return Ok(());
}

let all_bounds = stack
let bounds = stack
.obligation
.param_env
.caller_bounds()
.iter()
.filter(|p| !p.references_error())
.filter_map(|p| p.as_trait_clause());

// Micro-optimization: filter out predicates relating to different traits.
let matching_bounds =
all_bounds.filter(|p| p.def_id() == stack.obligation.predicate.def_id());
.filter_map(|p| p.as_trait_clause())
// Micro-optimization: filter out predicates relating to different traits.
.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.
for bound in matching_bounds {
if bound.skip_binder().polarity != stack.obligation.predicate.skip_binder().polarity {
continue;
}

for bound in bounds {
// FIXME(oli-obk): it is suspicious that we are dropping the constness and
// polarity here.
let wc = self.where_clause_may_apply(stack, bound.map_bound(|t| t.trait_ref))?;
Expand Down

0 comments on commit 6bfc340

Please sign in to comment.