Auto merge of #124203 - lukas-code:delete-deleting-caches, r=compiler-errors
fix normalizing in different `ParamEnv`s with the same `InferCtxt` This PR changes the key of the projection cache from just `AliasTy` to `(AliasTy, ParamEnv)` to allow normalizing in different `ParamEnv`s without resetting caches. Previously, normalizing the same alias in different param envs would always reuse the cached result from the first normalization, which is incorrect if the projection clauses in the param env have changed. Fixing this bug allows us to get rid of `InferCtxt::clear_caches`, which was only used by the `AutoTraitFinder`, because it requires normalizing in different param envs. r? `@fmease`
This commit is contained in:
commit
1b3fba066c
8 changed files with 25 additions and 29 deletions
|
@ -1521,15 +1521,6 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
closure_kind_ty.to_opt_closure_kind()
|
||||
}
|
||||
|
||||
/// Clears the selection, evaluation, and projection caches. This is useful when
|
||||
/// repeatedly attempting to select an `Obligation` while changing only
|
||||
/// its `ParamEnv`, since `FulfillmentContext` doesn't use probing.
|
||||
pub fn clear_caches(&self) {
|
||||
self.selection_cache.clear();
|
||||
self.evaluation_cache.clear();
|
||||
self.inner.borrow_mut().projection_cache().clear();
|
||||
}
|
||||
|
||||
pub fn universe(&self) -> ty::UniverseIndex {
|
||||
self.universe.get()
|
||||
}
|
||||
|
|
|
@ -78,11 +78,12 @@ pub struct ProjectionCacheStorage<'tcx> {
|
|||
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
|
||||
pub struct ProjectionCacheKey<'tcx> {
|
||||
ty: ty::AliasTy<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx> ProjectionCacheKey<'tcx> {
|
||||
pub fn new(ty: ty::AliasTy<'tcx>) -> Self {
|
||||
Self { ty }
|
||||
pub fn new(ty: ty::AliasTy<'tcx>, param_env: ty::ParamEnv<'tcx>) -> Self {
|
||||
Self { ty, param_env }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue