about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-01-28 20:26:24 +0000
committerbors <bors@rust-lang.org>2020-01-28 20:26:24 +0000
commit3761dcd3467441f78939ccb3b341b03b6a7558d7 (patch)
tree9db360c58dde696d24eeb1f733cd1ec458743850
parentac2f3fa41ac5ae8425b959f955bb7433b7c57aea (diff)
parent474d0e33717062696be4c9799ce9822bf7b56fc2 (diff)
Auto merge of #68606 - jonas-schievink:normalize-fastpath, r=Zoxc
Add an early-exit to `QueryNormalizer::fold_ty`

Pulled out from https://github.com/rust-lang/rust/pull/68524, this results in a ~60-70% reduction in compile time for the await-call-tree benchmarks. This should unblock https://github.com/rust-lang/rust/issues/67982 as well.

r? @Zoxc
-rw-r--r--src/librustc/traits/query/normalize.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/librustc/traits/query/normalize.rs b/src/librustc/traits/query/normalize.rs
index 8f23f98a2a4..20d7b556377 100644
--- a/src/librustc/traits/query/normalize.rs
+++ b/src/librustc/traits/query/normalize.rs
@@ -81,6 +81,10 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
     }
 
     fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
+        if !ty.has_projections() {
+            return ty;
+        }
+
         let ty = ty.super_fold_with(self);
         match ty.kind {
             ty::Opaque(def_id, substs) if !substs.has_escaping_bound_vars() => {