diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2019-12-02 17:44:16 +0200 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2019-12-02 18:33:26 +0200 |
| commit | a266ea0bd03508724341a2382b5ba8a22aa6e667 (patch) | |
| tree | 76b742c75975ad23e820783a532945af424f32db | |
| parent | 1d1298ea5f83b1e6714f25b0b63a78c37712b240 (diff) | |
| download | rust-a266ea0bd03508724341a2382b5ba8a22aa6e667.tar.gz rust-a266ea0bd03508724341a2382b5ba8a22aa6e667.zip | |
rustc: allow non-empty ParamEnv's in global trait select/eval caches.
| -rw-r--r-- | src/librustc/traits/select.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 4e172f50b8f..94a77c553e5 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; } |
