@@ -32,6 +32,7 @@ use rustc_trait_selection::traits::{
3232} ;
3333
3434use std:: cell:: LazyCell ;
35+ use std:: iter;
3536use std:: ops:: { ControlFlow , Deref } ;
3637
3738pub ( super ) struct WfCheckingCtxt < ' a , ' tcx > {
@@ -1309,7 +1310,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
13091310 let infcx = wfcx. infcx ;
13101311 let tcx = wfcx. tcx ( ) ;
13111312
1312- let predicates = tcx. predicates_of ( def_id. to_def_id ( ) ) ;
1313+ let predicates = tcx. bound_predicates_of ( def_id. to_def_id ( ) ) ;
13131314 let generics = tcx. generics_of ( def_id) ;
13141315
13151316 let is_our_default = |def : & ty:: GenericParamDef | match def. kind {
@@ -1410,6 +1411,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
14101411
14111412 // Now we build the substituted predicates.
14121413 let default_obligations = predicates
1414+ . 0
14131415 . predicates
14141416 . iter ( )
14151417 . flat_map ( |& ( pred, sp) | {
@@ -1440,13 +1442,13 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
14401442 }
14411443 let mut param_count = CountParams :: default ( ) ;
14421444 let has_region = pred. visit_with ( & mut param_count) . is_break ( ) ;
1443- let substituted_pred = ty :: EarlyBinder ( pred) . subst ( tcx, substs) ;
1445+ let substituted_pred = predicates . rebind ( pred) . subst ( tcx, substs) ;
14441446 // Don't check non-defaulted params, dependent defaults (including lifetimes)
14451447 // or preds with multiple params.
14461448 if substituted_pred. has_non_region_param ( ) || param_count. params . len ( ) > 1 || has_region
14471449 {
14481450 None
1449- } else if predicates. predicates . iter ( ) . any ( |& ( p, _) | p == substituted_pred) {
1451+ } else if predicates. 0 . predicates . iter ( ) . any ( |& ( p, _) | p == substituted_pred) {
14501452 // Avoid duplication of predicates that contain no parameters, for example.
14511453 None
14521454 } else {
@@ -1472,21 +1474,22 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
14721474 traits:: Obligation :: new ( tcx, cause, wfcx. param_env , pred)
14731475 } ) ;
14741476
1475- let predicates = predicates. instantiate_identity ( tcx) ;
1477+ let predicates = predicates. 0 . instantiate_identity ( tcx) ;
14761478
14771479 let predicates = wfcx. normalize ( span, None , predicates) ;
14781480
14791481 debug ! ( ?predicates. predicates) ;
14801482 assert_eq ! ( predicates. predicates. len( ) , predicates. spans. len( ) ) ;
1481- let wf_obligations = predicates. into_iter ( ) . flat_map ( |( p, sp) | {
1482- traits:: wf:: predicate_obligations (
1483- infcx,
1484- wfcx. param_env . without_const ( ) ,
1485- wfcx. body_id ,
1486- p,
1487- sp,
1488- )
1489- } ) ;
1483+ let wf_obligations =
1484+ iter:: zip ( & predicates. predicates , & predicates. spans ) . flat_map ( |( & p, & sp) | {
1485+ traits:: wf:: predicate_obligations (
1486+ infcx,
1487+ wfcx. param_env . without_const ( ) ,
1488+ wfcx. body_id ,
1489+ p,
1490+ sp,
1491+ )
1492+ } ) ;
14901493
14911494 let obligations: Vec < _ > = wf_obligations. chain ( default_obligations) . collect ( ) ;
14921495 wfcx. register_obligations ( obligations) ;
0 commit comments