@@ -225,9 +225,15 @@ struct FulfillProcessor<'a, 'tcx> {
225225 selcx : SelectionContext < ' a , ' tcx > ,
226226}
227227
228- fn mk_pending < ' tcx > ( os : PredicateObligations < ' tcx > ) -> PendingPredicateObligations < ' tcx > {
228+ fn mk_pending < ' tcx > (
229+ parent : & PredicateObligation < ' tcx > ,
230+ os : PredicateObligations < ' tcx > ,
231+ ) -> PendingPredicateObligations < ' tcx > {
229232 os. into_iter ( )
230- . map ( |o| PendingPredicateObligation { obligation : o, stalled_on : vec ! [ ] } )
233+ . map ( |mut o| {
234+ o. set_depth_from_parent ( parent. recursion_depth ) ;
235+ PendingPredicateObligation { obligation : o, stalled_on : vec ! [ ] }
236+ } )
231237 . collect ( )
232238}
233239
@@ -341,7 +347,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
341347 ) ;
342348 if predicate != obligation. predicate {
343349 obligations. push ( obligation. with ( infcx. tcx , predicate) ) ;
344- return ProcessResult :: Changed ( mk_pending ( obligations) ) ;
350+ return ProcessResult :: Changed ( mk_pending ( obligation , obligations) ) ;
345351 }
346352 }
347353 let binder = obligation. predicate . kind ( ) ;
@@ -385,7 +391,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
385391 let mut obligations = PredicateObligations :: with_capacity ( 1 ) ;
386392 obligations. push ( obligation. with ( infcx. tcx , pred) ) ;
387393
388- ProcessResult :: Changed ( mk_pending ( obligations) )
394+ ProcessResult :: Changed ( mk_pending ( obligation , obligations) )
389395 }
390396 ty:: PredicateKind :: Ambiguous => ProcessResult :: Unchanged ,
391397 ty:: PredicateKind :: NormalizesTo ( ..) => {
@@ -410,6 +416,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
410416 let host_obligation = obligation. with ( infcx. tcx , data) ;
411417
412418 self . process_host_obligation (
419+ obligation,
413420 host_obligation,
414421 & mut pending_obligation. stalled_on ,
415422 )
@@ -486,7 +493,10 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
486493 // `<lhs_ty as Add<rhs_ty>>::Output` when this is an `Expr` representing
487494 // `lhs + rhs`.
488495 ty:: ConstKind :: Expr ( _) => {
489- return ProcessResult :: Changed ( mk_pending ( PredicateObligations :: new ( ) ) ) ;
496+ return ProcessResult :: Changed ( mk_pending (
497+ obligation,
498+ PredicateObligations :: new ( ) ,
499+ ) ) ;
490500 }
491501 ty:: ConstKind :: Placeholder ( _) => {
492502 bug ! ( "placeholder const {:?} in old solver" , ct)
@@ -503,7 +513,10 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
503513 ct_ty,
504514 ty,
505515 ) {
506- Ok ( inf_ok) => ProcessResult :: Changed ( mk_pending ( inf_ok. into_obligations ( ) ) ) ,
516+ Ok ( inf_ok) => ProcessResult :: Changed ( mk_pending (
517+ obligation,
518+ inf_ok. into_obligations ( ) ,
519+ ) ) ,
507520 Err ( _) => ProcessResult :: Error ( FulfillmentErrorCode :: Select (
508521 SelectionError :: ConstArgHasWrongType { ct, ct_ty, expected_ty : ty } ,
509522 ) ) ,
@@ -537,7 +550,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
537550 vec ! [ TyOrConstInferVar :: maybe_from_generic_arg( arg) . unwrap( ) ] ;
538551 ProcessResult :: Unchanged
539552 }
540- Some ( os) => ProcessResult :: Changed ( mk_pending ( os) ) ,
553+ Some ( os) => ProcessResult :: Changed ( mk_pending ( obligation , os) ) ,
541554 }
542555 }
543556
@@ -557,7 +570,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
557570 for subobligation in & mut ok. obligations {
558571 subobligation. set_depth_from_parent ( obligation. recursion_depth ) ;
559572 }
560- ProcessResult :: Changed ( mk_pending ( ok. obligations ) )
573+ ProcessResult :: Changed ( mk_pending ( obligation , ok. obligations ) )
561574 }
562575 Ok ( Err ( err) ) => {
563576 let expected_found = if subtype. a_is_expected {
@@ -582,7 +595,9 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
582595 vec ! [ TyOrConstInferVar :: Ty ( a) , TyOrConstInferVar :: Ty ( b) ] ;
583596 ProcessResult :: Unchanged
584597 }
585- Ok ( Ok ( ok) ) => ProcessResult :: Changed ( mk_pending ( ok. obligations ) ) ,
598+ Ok ( Ok ( ok) ) => {
599+ ProcessResult :: Changed ( mk_pending ( obligation, ok. obligations ) )
600+ }
586601 Ok ( Err ( err) ) => {
587602 let expected_found = ExpectedFound :: new ( coerce. b , coerce. a ) ;
588603 ProcessResult :: Error ( FulfillmentErrorCode :: Subtype ( expected_found, err) )
@@ -645,6 +660,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
645660 )
646661 {
647662 return ProcessResult :: Changed ( mk_pending (
663+ obligation,
648664 new_obligations. into_obligations ( ) ,
649665 ) ) ;
650666 }
@@ -659,6 +675,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
659675 . eq ( DefineOpaqueTypes :: Yes , c1, c2)
660676 {
661677 return ProcessResult :: Changed ( mk_pending (
678+ obligation,
662679 new_obligations. into_obligations ( ) ,
663680 ) ) ;
664681 }
@@ -704,9 +721,10 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
704721 c1,
705722 c2,
706723 ) {
707- Ok ( inf_ok) => {
708- ProcessResult :: Changed ( mk_pending ( inf_ok. into_obligations ( ) ) )
709- }
724+ Ok ( inf_ok) => ProcessResult :: Changed ( mk_pending (
725+ obligation,
726+ inf_ok. into_obligations ( ) ,
727+ ) ) ,
710728 Err ( err) => {
711729 ProcessResult :: Error ( FulfillmentErrorCode :: ConstEquate (
712730 ExpectedFound :: new ( c1, c2) ,
@@ -790,7 +808,7 @@ impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> {
790808 match self . selcx . poly_select ( & trait_obligation) {
791809 Ok ( Some ( impl_source) ) => {
792810 debug ! ( "selecting trait at depth {} yielded Ok(Some)" , obligation. recursion_depth) ;
793- ProcessResult :: Changed ( mk_pending ( impl_source. nested_obligations ( ) ) )
811+ ProcessResult :: Changed ( mk_pending ( obligation , impl_source. nested_obligations ( ) ) )
794812 }
795813 Ok ( None ) => {
796814 debug ! ( "selecting trait at depth {} yielded Ok(None)" , obligation. recursion_depth) ;
@@ -854,7 +872,7 @@ impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> {
854872 }
855873
856874 match project:: poly_project_and_unify_term ( & mut self . selcx , & project_obligation) {
857- ProjectAndUnifyResult :: Holds ( os) => ProcessResult :: Changed ( mk_pending ( os) ) ,
875+ ProjectAndUnifyResult :: Holds ( os) => ProcessResult :: Changed ( mk_pending ( obligation , os) ) ,
858876 ProjectAndUnifyResult :: FailedNormalization => {
859877 stalled_on. clear ( ) ;
860878 stalled_on. extend ( args_infer_vars (
@@ -868,7 +886,7 @@ impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> {
868886 let mut obligations = PredicateObligations :: with_capacity ( 1 ) ;
869887 obligations. push ( project_obligation. with ( tcx, project_obligation. predicate ) ) ;
870888
871- ProcessResult :: Changed ( mk_pending ( obligations) )
889+ ProcessResult :: Changed ( mk_pending ( obligation , obligations) )
872890 }
873891 ProjectAndUnifyResult :: MismatchedProjectionTypes ( e) => {
874892 ProcessResult :: Error ( FulfillmentErrorCode :: Project ( e) )
@@ -878,11 +896,12 @@ impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> {
878896
879897 fn process_host_obligation (
880898 & mut self ,
899+ obligation : & PredicateObligation < ' tcx > ,
881900 host_obligation : HostEffectObligation < ' tcx > ,
882901 stalled_on : & mut Vec < TyOrConstInferVar > ,
883902 ) -> ProcessResult < PendingPredicateObligation < ' tcx > , FulfillmentErrorCode < ' tcx > > {
884903 match effects:: evaluate_host_effect_obligation ( & mut self . selcx , & host_obligation) {
885- Ok ( nested) => ProcessResult :: Changed ( mk_pending ( nested) ) ,
904+ Ok ( nested) => ProcessResult :: Changed ( mk_pending ( obligation , nested) ) ,
886905 Err ( effects:: EvaluationFailure :: Ambiguous ) => {
887906 stalled_on. clear ( ) ;
888907 stalled_on. extend ( args_infer_vars (
0 commit comments