@@ -204,7 +204,10 @@ struct TraitObligationStack<'prev, 'tcx> {
204
204
#[ derive( Clone , Default ) ]
205
205
pub struct SelectionCache < ' tcx > {
206
206
hashmap : Lock <
207
- FxHashMap < ty:: TraitRef < ' tcx > , WithDepNode < SelectionResult < ' tcx , SelectionCandidate < ' tcx > > > > ,
207
+ FxHashMap <
208
+ ty:: ParamEnvAnd < ' tcx , ty:: TraitRef < ' tcx > > ,
209
+ WithDepNode < SelectionResult < ' tcx , SelectionCandidate < ' tcx > > > ,
210
+ > ,
208
211
> ,
209
212
}
210
213
@@ -490,7 +493,9 @@ impl<'tcx> From<OverflowError> for SelectionError<'tcx> {
490
493
491
494
#[ derive( Clone , Default ) ]
492
495
pub struct EvaluationCache < ' tcx > {
493
- hashmap : Lock < FxHashMap < ty:: PolyTraitRef < ' tcx > , WithDepNode < EvaluationResult > > > ,
496
+ hashmap : Lock <
497
+ FxHashMap < ty:: ParamEnvAnd < ' tcx , ty:: PolyTraitRef < ' tcx > > , WithDepNode < EvaluationResult > > ,
498
+ > ,
494
499
}
495
500
496
501
impl < ' cx , ' tcx > SelectionContext < ' cx , ' tcx > {
@@ -1143,15 +1148,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1143
1148
let tcx = self . tcx ( ) ;
1144
1149
if self . can_use_global_caches ( param_env) {
1145
1150
let cache = tcx. evaluation_cache . hashmap . borrow ( ) ;
1146
- if let Some ( cached) = cache. get ( & trait_ref) {
1151
+ if let Some ( cached) = cache. get ( & param_env . and ( trait_ref) ) {
1147
1152
return Some ( cached. get ( tcx) ) ;
1148
1153
}
1149
1154
}
1150
1155
self . infcx
1151
1156
. evaluation_cache
1152
1157
. hashmap
1153
1158
. borrow ( )
1154
- . get ( & trait_ref)
1159
+ . get ( & param_env . and ( trait_ref) )
1155
1160
. map ( |v| v. get ( tcx) )
1156
1161
}
1157
1162
@@ -1182,7 +1187,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1182
1187
. evaluation_cache
1183
1188
. hashmap
1184
1189
. borrow_mut ( )
1185
- . insert ( trait_ref, WithDepNode :: new ( dep_node, result) ) ;
1190
+ . insert ( param_env . and ( trait_ref) , WithDepNode :: new ( dep_node, result) ) ;
1186
1191
return ;
1187
1192
}
1188
1193
}
@@ -1195,7 +1200,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1195
1200
. evaluation_cache
1196
1201
. hashmap
1197
1202
. borrow_mut ( )
1198
- . insert ( trait_ref, WithDepNode :: new ( dep_node, result) ) ;
1203
+ . insert ( param_env . and ( trait_ref) , WithDepNode :: new ( dep_node, result) ) ;
1199
1204
}
1200
1205
1201
1206
/// For various reasons, it's possible for a subobligation
@@ -1575,7 +1580,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1575
1580
// rule seems to be pretty clearly safe and also still retains
1576
1581
// a very high hit rate (~95% when compiling rustc).
1577
1582
if !param_env. caller_bounds . is_empty ( ) {
1578
- return false ;
1583
+ // return false;
1579
1584
}
1580
1585
1581
1586
// Avoid using the master cache during coherence and just rely
@@ -1602,15 +1607,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1602
1607
let trait_ref = & cache_fresh_trait_pred. skip_binder ( ) . trait_ref ;
1603
1608
if self . can_use_global_caches ( param_env) {
1604
1609
let cache = tcx. selection_cache . hashmap . borrow ( ) ;
1605
- if let Some ( cached) = cache. get ( & trait_ref) {
1610
+ if let Some ( cached) = cache. get ( & param_env . and ( * trait_ref) ) {
1606
1611
return Some ( cached. get ( tcx) ) ;
1607
1612
}
1608
1613
}
1609
1614
self . infcx
1610
1615
. selection_cache
1611
1616
. hashmap
1612
1617
. borrow ( )
1613
- . get ( trait_ref)
1618
+ . get ( & param_env . and ( * trait_ref) )
1614
1619
. map ( |v| v. get ( tcx) )
1615
1620
}
1616
1621
@@ -1671,7 +1676,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1671
1676
tcx. selection_cache
1672
1677
. hashmap
1673
1678
. borrow_mut ( )
1674
- . insert ( trait_ref, WithDepNode :: new ( dep_node, candidate) ) ;
1679
+ . insert ( param_env . and ( trait_ref) , WithDepNode :: new ( dep_node, candidate) ) ;
1675
1680
return ;
1676
1681
}
1677
1682
}
@@ -1685,7 +1690,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1685
1690
. selection_cache
1686
1691
. hashmap
1687
1692
. borrow_mut ( )
1688
- . insert ( trait_ref, WithDepNode :: new ( dep_node, candidate) ) ;
1693
+ . insert ( param_env . and ( trait_ref) , WithDepNode :: new ( dep_node, candidate) ) ;
1689
1694
}
1690
1695
1691
1696
fn assemble_candidates < ' o > (
0 commit comments