From a266ea0bd03508724341a2382b5ba8a22aa6e667 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Mon, 2 Dec 2019 17:44:16 +0200 Subject: [PATCH] rustc: allow non-empty ParamEnv's in global trait select/eval caches. --- src/librustc/traits/select.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 4e172f50b8f2..94a77c553e53 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -1572,14 +1572,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { /// Do note that if the type itself is not in the /// global tcx, the local caches will be used. fn can_use_global_caches(&self, param_env: ty::ParamEnv<'tcx>) -> bool { - // If there are any where-clauses in scope, then we always use - // a cache local to this particular scope. Otherwise, we - // switch to a global cache. We used to try and draw - // finer-grained distinctions, but that led to a serious of - // annoying and weird bugs like #22019 and #18290. This simple - // rule seems to be pretty clearly safe and also still retains - // a very high hit rate (~95% when compiling rustc). - if !param_env.caller_bounds.is_empty() { + // If there are any e.g. inference variables in the `ParamEnv`, then we + // always use a cache local to this particular scope. Otherwise, we + // switch to a global cache. + if param_env.has_local_value() { return false; }