Do not use ParamEnv::and to cache param-env with candidate
This commit is contained in:
parent
551b4fa395
commit
8588f79802
3 changed files with 20 additions and 12 deletions
|
@ -1046,11 +1046,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
let tcx = self.tcx();
|
||||
if self.can_use_global_caches(param_env) {
|
||||
if let Some(res) = tcx.evaluation_cache.get(¶m_env.and(trait_pred), tcx) {
|
||||
if let Some(res) = tcx.evaluation_cache.get(&(param_env, trait_pred), tcx) {
|
||||
return Some(res);
|
||||
}
|
||||
}
|
||||
self.infcx.evaluation_cache.get(¶m_env.and(trait_pred), tcx)
|
||||
self.infcx.evaluation_cache.get(&(param_env, trait_pred), tcx)
|
||||
}
|
||||
|
||||
fn insert_evaluation_cache(
|
||||
|
@ -1081,13 +1081,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// FIXME: Due to #50507 this overwrites the different values
|
||||
// This should be changed to use HashMapExt::insert_same
|
||||
// when that is fixed
|
||||
self.tcx().evaluation_cache.insert(param_env.and(trait_pred), dep_node, result);
|
||||
self.tcx().evaluation_cache.insert((param_env, trait_pred), dep_node, result);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
debug!(?trait_pred, ?result, "insert_evaluation_cache");
|
||||
self.infcx.evaluation_cache.insert(param_env.and(trait_pred), dep_node, result);
|
||||
self.infcx.evaluation_cache.insert((param_env, trait_pred), dep_node, result);
|
||||
}
|
||||
|
||||
/// For various reasons, it's possible for a subobligation
|
||||
|
@ -1297,11 +1297,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
pred.remap_constness(tcx, &mut param_env);
|
||||
|
||||
if self.can_use_global_caches(param_env) {
|
||||
if let Some(res) = tcx.selection_cache.get(¶m_env.and(pred), tcx) {
|
||||
if let Some(res) = tcx.selection_cache.get(&(param_env, pred), tcx) {
|
||||
return Some(res);
|
||||
}
|
||||
}
|
||||
self.infcx.selection_cache.get(¶m_env.and(pred), tcx)
|
||||
self.infcx.selection_cache.get(&(param_env, pred), tcx)
|
||||
}
|
||||
|
||||
/// Determines whether can we safely cache the result
|
||||
|
@ -1361,14 +1361,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
if !candidate.needs_infer() {
|
||||
debug!(?pred, ?candidate, "insert_candidate_cache global");
|
||||
// This may overwrite the cache with the same value.
|
||||
tcx.selection_cache.insert(param_env.and(pred), dep_node, candidate);
|
||||
tcx.selection_cache.insert((param_env, pred), dep_node, candidate);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
debug!(?pred, ?candidate, "insert_candidate_cache local");
|
||||
self.infcx.selection_cache.insert(param_env.and(pred), dep_node, candidate);
|
||||
self.infcx.selection_cache.insert((param_env, pred), dep_node, candidate);
|
||||
}
|
||||
|
||||
/// Matches a predicate against the bounds of its self type.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue