1
Fork 0

rustc: allow non-empty ParamEnv's in global trait select/eval caches.

This commit is contained in:
Eduard-Mihai Burtescu 2019-12-02 17:44:16 +02:00
parent 1d1298ea5f
commit a266ea0bd0

View file

@ -1572,14 +1572,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
/// Do note that if the type itself is not in the /// Do note that if the type itself is not in the
/// global tcx, the local caches will be used. /// global tcx, the local caches will be used.
fn can_use_global_caches(&self, param_env: ty::ParamEnv<'tcx>) -> bool { fn can_use_global_caches(&self, param_env: ty::ParamEnv<'tcx>) -> bool {
// If there are any where-clauses in scope, then we always use // If there are any e.g. inference variables in the `ParamEnv`, then we
// a cache local to this particular scope. Otherwise, we // always use a cache local to this particular scope. Otherwise, we
// switch to a global cache. We used to try and draw // switch to a global cache.
// finer-grained distinctions, but that led to a serious of if param_env.has_local_value() {
// 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() {
return false; return false;
} }