Skip to content

Commit a266ea0

Browse files
committed
rustc: allow non-empty ParamEnv's in global trait select/eval caches.
1 parent 1d1298e commit a266ea0

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/librustc/traits/select.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -1572,14 +1572,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
15721572
/// Do note that if the type itself is not in the
15731573
/// global tcx, the local caches will be used.
15741574
fn can_use_global_caches(&self, param_env: ty::ParamEnv<'tcx>) -> bool {
1575-
// If there are any where-clauses in scope, then we always use
1576-
// a cache local to this particular scope. Otherwise, we
1577-
// switch to a global cache. We used to try and draw
1578-
// finer-grained distinctions, but that led to a serious of
1579-
// annoying and weird bugs like #22019 and #18290. This simple
1580-
// rule seems to be pretty clearly safe and also still retains
1581-
// a very high hit rate (~95% when compiling rustc).
1582-
if !param_env.caller_bounds.is_empty() {
1575+
// If there are any e.g. inference variables in the `ParamEnv`, then we
1576+
// always use a cache local to this particular scope. Otherwise, we
1577+
// switch to a global cache.
1578+
if param_env.has_local_value() {
15831579
return false;
15841580
}
15851581

0 commit comments

Comments
 (0)