summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-04-23 23:06:50 +0000
committerbors <bors@rust-lang.org>2017-04-23 23:06:50 +0000
commit15ce54096a589de277771ad1f55a334fe2661a64 (patch)
treec719164d29a931a1175404c29f525c0f27fdddf5
parent2bd4b5c6db1468235f730bce403bf657123ecc57 (diff)
parenteadb049799162fc5265f404bd4c6671d223e5dd2 (diff)
downloadrust-15ce54096a589de277771ad1f55a334fe2661a64.tar.gz
Auto merge of #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
-rw-r--r--src/librustc/traits/select.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs
index e61e5743790..207016170fa 100644
--- a/src/librustc/traits/select.rs
+++ b/src/librustc/traits/select.rs
@@ -1300,8 +1300,13 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
.iter()
.filter_map(|o| o.to_opt_poly_trait_ref());
+ // micro-optimization: filter out predicates relating to different
+ // traits.
let matching_bounds =
- all_bounds.filter(
+ all_bounds.filter(|p| p.def_id() == stack.obligation.predicate.def_id());
+
+ let matching_bounds =
+ matching_bounds.filter(
|bound| self.evaluate_where_clause(stack, bound.clone()).may_apply());
let param_candidates =