@@ -1231,19 +1231,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
12311231 return None ;
12321232 }
12331233 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 ( ) ;
12361235 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) {
12411237 return Some ( res) ;
12421238 }
12431239 }
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)
12471241 }
12481242
12491243 /// Determines whether can we safely cache the result
@@ -1288,36 +1282,27 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
12881282 ) {
12891283 let tcx = self . tcx ( ) ;
12901284 let pred = cache_fresh_trait_pred. skip_binder ( ) ;
1291- let trait_ref = pred. trait_ref ;
12921285
12931286 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" ) ;
12951288 return ;
12961289 }
12971290
12981291 if self . can_use_global_caches ( param_env) {
12991292 if let Err ( Overflow ) = candidate {
13001293 // 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 ( ) {
13021295 if !candidate. needs_infer ( ) {
1303- debug ! ( ?trait_ref , ?candidate, "insert_candidate_cache global" ) ;
1296+ debug ! ( ?pred , ?candidate, "insert_candidate_cache global" ) ;
13041297 // 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) ;
13101299 return ;
13111300 }
13121301 }
13131302 }
13141303
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) ;
13211306 }
13221307
13231308 /// Matches a predicate against the bounds of its self type.
0 commit comments