Skip to content

Commit 63f5e68

Browse files
committed
[HACK] Binderize ProjectionCacheKey.
1 parent c2ecd3a commit 63f5e68

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

compiler/rustc_infer/src/traits/project.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ pub struct ProjectionCacheStorage<'tcx> {
7777

7878
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
7979
pub struct ProjectionCacheKey<'tcx> {
80-
ty: ty::ProjectionTy<'tcx>,
80+
ty: ty::Binder<'tcx, ty::ProjectionTy<'tcx>>,
8181
}
8282

8383
impl<'tcx> ProjectionCacheKey<'tcx> {
84-
pub fn new(ty: ty::ProjectionTy<'tcx>) -> Self {
84+
pub fn new(ty: ty::Binder<'tcx, ty::ProjectionTy<'tcx>>) -> Self {
8585
Self { ty }
8686
}
8787
}

compiler/rustc_trait_selection/src/traits/project.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>(
958958
let use_cache = !selcx.is_intercrate();
959959

960960
let projection_ty = infcx.resolve_vars_if_possible(projection_ty);
961-
let cache_key = ProjectionCacheKey::new(projection_ty);
961+
let cache_key = ProjectionCacheKey::new(ty::Binder::dummy(projection_ty));
962962

963963
// FIXME(#20304) For now, I am caching here, which is good, but it
964964
// means we don't capture the type variables that are created in
@@ -2123,14 +2123,12 @@ impl<'cx, 'tcx> ProjectionCacheKeyExt<'cx, 'tcx> for ProjectionCacheKey<'tcx> {
21232123
let infcx = selcx.infcx();
21242124
// We don't do cross-snapshot caching of obligations with escaping regions,
21252125
// so there's no cache key to use
2126-
predicate.no_bound_vars().map(|predicate| {
2127-
ProjectionCacheKey::new(
2128-
// We don't attempt to match up with a specific type-variable state
2129-
// from a specific call to `opt_normalize_projection_type` - if
2130-
// there's no precise match, the original cache entry is "stranded"
2131-
// anyway.
2132-
infcx.resolve_vars_if_possible(predicate.projection_ty),
2133-
)
2134-
})
2126+
Some(ProjectionCacheKey::new(predicate.map_bound(|predicate| {
2127+
// We don't attempt to match up with a specific type-variable state
2128+
// from a specific call to `opt_normalize_projection_type` - if
2129+
// there's no precise match, the original cache entry is "stranded"
2130+
// anyway.
2131+
infcx.resolve_vars_if_possible(predicate.projection_ty)
2132+
})))
21352133
}
21362134
}

0 commit comments

Comments
 (0)