@@ -1231,19 +1231,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1231
1231
return None ;
1232
1232
}
1233
1233
let tcx = self . tcx ( ) ;
1234
- let pred = & cache_fresh_trait_pred. skip_binder ( ) ;
1235
- let trait_ref = pred. trait_ref ;
1234
+ let pred = cache_fresh_trait_pred. skip_binder ( ) ;
1236
1235
if self . can_use_global_caches ( param_env) {
1237
- if let Some ( res) = tcx
1238
- . selection_cache
1239
- . get ( & ( param_env. and ( trait_ref) . with_constness ( pred. constness ) , pred. polarity ) , tcx)
1240
- {
1236
+ if let Some ( res) = tcx. selection_cache . get ( & param_env. and ( pred) , tcx) {
1241
1237
return Some ( res) ;
1242
1238
}
1243
1239
}
1244
- self . infcx
1245
- . selection_cache
1246
- . get ( & ( param_env. and ( trait_ref) . with_constness ( pred. constness ) , pred. polarity ) , tcx)
1240
+ self . infcx . selection_cache . get ( & param_env. and ( pred) , tcx)
1247
1241
}
1248
1242
1249
1243
/// Determines whether can we safely cache the result
@@ -1288,36 +1282,27 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1288
1282
) {
1289
1283
let tcx = self . tcx ( ) ;
1290
1284
let pred = cache_fresh_trait_pred. skip_binder ( ) ;
1291
- let trait_ref = pred. trait_ref ;
1292
1285
1293
1286
if !self . can_cache_candidate ( & candidate) {
1294
- debug ! ( ?trait_ref , ?candidate, "insert_candidate_cache - candidate is not cacheable" ) ;
1287
+ debug ! ( ?pred , ?candidate, "insert_candidate_cache - candidate is not cacheable" ) ;
1295
1288
return ;
1296
1289
}
1297
1290
1298
1291
if self . can_use_global_caches ( param_env) {
1299
1292
if let Err ( Overflow ) = candidate {
1300
1293
// Don't cache overflow globally; we only produce this in certain modes.
1301
- } else if !trait_ref . needs_infer ( ) {
1294
+ } else if !pred . needs_infer ( ) {
1302
1295
if !candidate. needs_infer ( ) {
1303
- debug ! ( ?trait_ref , ?candidate, "insert_candidate_cache global" ) ;
1296
+ debug ! ( ?pred , ?candidate, "insert_candidate_cache global" ) ;
1304
1297
// This may overwrite the cache with the same value.
1305
- tcx. selection_cache . insert (
1306
- ( param_env. and ( trait_ref) . with_constness ( pred. constness ) , pred. polarity ) ,
1307
- dep_node,
1308
- candidate,
1309
- ) ;
1298
+ tcx. selection_cache . insert ( param_env. and ( pred) , dep_node, candidate) ;
1310
1299
return ;
1311
1300
}
1312
1301
}
1313
1302
}
1314
1303
1315
- debug ! ( ?trait_ref, ?candidate, "insert_candidate_cache local" ) ;
1316
- self . infcx . selection_cache . insert (
1317
- ( param_env. and ( trait_ref) . with_constness ( pred. constness ) , pred. polarity ) ,
1318
- dep_node,
1319
- candidate,
1320
- ) ;
1304
+ debug ! ( ?pred, ?candidate, "insert_candidate_cache local" ) ;
1305
+ self . infcx . selection_cache . insert ( param_env. and ( pred) , dep_node, candidate) ;
1321
1306
}
1322
1307
1323
1308
/// Matches a predicate against the bounds of its self type.
0 commit comments