@@ -49,6 +49,7 @@ use rustc_middle::ty::{self, PolyProjectionPredicate, Upcast};
49
49
use rustc_middle:: ty:: { Ty , TyCtxt , TypeFoldable , TypeVisitableExt } ;
50
50
use rustc_span:: symbol:: sym;
51
51
use rustc_span:: Symbol ;
52
+ use rustc_type_ir:: InferCtxtLike as _;
52
53
53
54
use std:: cell:: { Cell , RefCell } ;
54
55
use std:: cmp;
@@ -1559,13 +1560,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1559
1560
}
1560
1561
let tcx = self . tcx ( ) ;
1561
1562
let pred = cache_fresh_trait_pred. skip_binder ( ) ;
1563
+ let opaques = self . infcx . defining_opaque_types ( ) ;
1562
1564
1563
1565
if self . can_use_global_caches ( param_env) {
1564
- if let Some ( res) = tcx. selection_cache . get ( & ( param_env, pred) , tcx) {
1566
+ if let Some ( res) = tcx. selection_cache . get ( & ( opaques , param_env, pred) , tcx) {
1565
1567
return Some ( res) ;
1566
1568
}
1567
1569
}
1568
- self . infcx . selection_cache . get ( & ( param_env, pred) , tcx)
1570
+ self . infcx . selection_cache . get ( & ( opaques , param_env, pred) , tcx)
1569
1571
}
1570
1572
1571
1573
/// Determines whether can we safely cache the result
@@ -1611,6 +1613,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1611
1613
) {
1612
1614
let tcx = self . tcx ( ) ;
1613
1615
let pred = cache_fresh_trait_pred. skip_binder ( ) ;
1616
+ let opaques = self . infcx . defining_opaque_types ( ) ;
1614
1617
1615
1618
if !self . can_cache_candidate ( & candidate) {
1616
1619
debug ! ( ?pred, ?candidate, "insert_candidate_cache - candidate is not cacheable" ) ;
@@ -1624,14 +1627,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1624
1627
if !candidate. has_infer ( ) {
1625
1628
debug ! ( ?pred, ?candidate, "insert_candidate_cache global" ) ;
1626
1629
// This may overwrite the cache with the same value.
1627
- tcx. selection_cache . insert ( ( param_env, pred) , dep_node, candidate) ;
1630
+ tcx. selection_cache . insert ( ( opaques , param_env, pred) , dep_node, candidate) ;
1628
1631
return ;
1629
1632
}
1630
1633
}
1631
1634
}
1632
1635
1633
1636
debug ! ( ?pred, ?candidate, "insert_candidate_cache local" ) ;
1634
- self . infcx . selection_cache . insert ( ( param_env, pred) , dep_node, candidate) ;
1637
+ self . infcx . selection_cache . insert ( ( opaques , param_env, pred) , dep_node, candidate) ;
1635
1638
}
1636
1639
1637
1640
/// Looks at the item bounds of the projection or opaque type.
0 commit comments