about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-03-29 22:27:16 +0000
committerbors <bors@rust-lang.org>2021-03-29 22:27:16 +0000
commit50489e3b0048af4df6f0a92bb43af8afce9b6652 (patch)
tree0be1b83baf49236360e85ef42dee7e8c78cd381c /src
parent48691ea6e639640f110b43e33d4aba1f07e7415c (diff)
parentf8b15d85ded26b45aeed62ea541008a91e922096 (diff)
downloadrust-50489e3b0048af4df6f0a92bb43af8afce9b6652.tar.gz
rust-50489e3b0048af4df6f0a92bb43af8afce9b6652.zip
Auto merge of #82864 - jyn514:short-circuit, r=GuillaumeGomez
rustdoc: Don't enter an infer_ctxt in get_blanket_impls for impls that aren't blanket impls

Less broken version of https://github.com/rust-lang/rust/pull/82856.

get_blanket_impls is a *very* hot region of rustdoc, so even small changes like this should help. Unfortunately I don't have benchmarks for this until https://github.com/rust-lang/rustc-perf/pull/802 is merged.
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/clean/blanket_impl.rs8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/librustdoc/clean/blanket_impl.rs b/src/librustdoc/clean/blanket_impl.rs
index 6e7164457ce..1bbaa60fe96 100644
--- a/src/librustdoc/clean/blanket_impl.rs
+++ b/src/librustdoc/clean/blanket_impl.rs
@@ -32,12 +32,8 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
                     trait_def_id, impl_def_id
                 );
                 let trait_ref = self.cx.tcx.impl_trait_ref(impl_def_id).unwrap();
-                let may_apply = self.cx.tcx.infer_ctxt().enter(|infcx| {
-                    match trait_ref.self_ty().kind() {
-                        ty::Param(_) => {}
-                        _ => return false,
-                    }
-
+                let is_param = matches!(trait_ref.self_ty().kind(), ty::Param(_));
+                let may_apply = is_param && self.cx.tcx.infer_ctxt().enter(|infcx| {
                     let substs = infcx.fresh_substs_for_item(DUMMY_SP, item_def_id);
                     let ty = ty.subst(infcx.tcx, substs);
                     let param_env = param_env.subst(infcx.tcx, substs);