Skip to content

Commit 15ce540

Browse files
committed
Auto merge of rust-lang#41486 - arielb1:select-where, r=eddyb
traits::select: quickly filter out predicates from other traits this improves most pre-trans passes's performance by ~1%. That missed the spring cleaning PR because I wanted to ship it. r? @eddyb
2 parents 2bd4b5c + eadb049 commit 15ce540

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/librustc/traits/select.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1300,8 +1300,13 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
13001300
.iter()
13011301
.filter_map(|o| o.to_opt_poly_trait_ref());
13021302

1303+
// micro-optimization: filter out predicates relating to different
1304+
// traits.
13031305
let matching_bounds =
1304-
all_bounds.filter(
1306+
all_bounds.filter(|p| p.def_id() == stack.obligation.predicate.def_id());
1307+
1308+
let matching_bounds =
1309+
matching_bounds.filter(
13051310
|bound| self.evaluate_where_clause(stack, bound.clone()).may_apply());
13061311

13071312
let param_candidates =

0 commit comments

Comments
 (0)