@@ -225,9 +225,15 @@ struct FulfillProcessor<'a, 'tcx> {
225
225
selcx : SelectionContext < ' a , ' tcx > ,
226
226
}
227
227
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 > {
229
232
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
+ } )
231
237
. collect ( )
232
238
}
233
239
@@ -341,7 +347,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
341
347
) ;
342
348
if predicate != obligation. predicate {
343
349
obligations. push ( obligation. with ( infcx. tcx , predicate) ) ;
344
- return ProcessResult :: Changed ( mk_pending ( obligations) ) ;
350
+ return ProcessResult :: Changed ( mk_pending ( obligation , obligations) ) ;
345
351
}
346
352
}
347
353
let binder = obligation. predicate . kind ( ) ;
@@ -385,7 +391,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
385
391
let mut obligations = PredicateObligations :: with_capacity ( 1 ) ;
386
392
obligations. push ( obligation. with ( infcx. tcx , pred) ) ;
387
393
388
- ProcessResult :: Changed ( mk_pending ( obligations) )
394
+ ProcessResult :: Changed ( mk_pending ( obligation , obligations) )
389
395
}
390
396
ty:: PredicateKind :: Ambiguous => ProcessResult :: Unchanged ,
391
397
ty:: PredicateKind :: NormalizesTo ( ..) => {
@@ -410,6 +416,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
410
416
let host_obligation = obligation. with ( infcx. tcx , data) ;
411
417
412
418
self . process_host_obligation (
419
+ obligation,
413
420
host_obligation,
414
421
& mut pending_obligation. stalled_on ,
415
422
)
@@ -486,7 +493,10 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
486
493
// `<lhs_ty as Add<rhs_ty>>::Output` when this is an `Expr` representing
487
494
// `lhs + rhs`.
488
495
ty:: ConstKind :: Expr ( _) => {
489
- return ProcessResult :: Changed ( mk_pending ( PredicateObligations :: new ( ) ) ) ;
496
+ return ProcessResult :: Changed ( mk_pending (
497
+ obligation,
498
+ PredicateObligations :: new ( ) ,
499
+ ) ) ;
490
500
}
491
501
ty:: ConstKind :: Placeholder ( _) => {
492
502
bug ! ( "placeholder const {:?} in old solver" , ct)
@@ -503,7 +513,10 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
503
513
ct_ty,
504
514
ty,
505
515
) {
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
+ ) ) ,
507
520
Err ( _) => ProcessResult :: Error ( FulfillmentErrorCode :: Select (
508
521
SelectionError :: ConstArgHasWrongType { ct, ct_ty, expected_ty : ty } ,
509
522
) ) ,
@@ -537,7 +550,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
537
550
vec ! [ TyOrConstInferVar :: maybe_from_generic_arg( arg) . unwrap( ) ] ;
538
551
ProcessResult :: Unchanged
539
552
}
540
- Some ( os) => ProcessResult :: Changed ( mk_pending ( os) ) ,
553
+ Some ( os) => ProcessResult :: Changed ( mk_pending ( obligation , os) ) ,
541
554
}
542
555
}
543
556
@@ -553,11 +566,8 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
553
566
vec ! [ TyOrConstInferVar :: Ty ( a) , TyOrConstInferVar :: Ty ( b) ] ;
554
567
ProcessResult :: Unchanged
555
568
}
556
- Ok ( Ok ( mut ok) ) => {
557
- for subobligation in & mut ok. obligations {
558
- subobligation. set_depth_from_parent ( obligation. recursion_depth ) ;
559
- }
560
- ProcessResult :: Changed ( mk_pending ( ok. obligations ) )
569
+ Ok ( Ok ( ok) ) => {
570
+ ProcessResult :: Changed ( mk_pending ( obligation, ok. obligations ) )
561
571
}
562
572
Ok ( Err ( err) ) => {
563
573
let expected_found = if subtype. a_is_expected {
@@ -582,7 +592,9 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
582
592
vec ! [ TyOrConstInferVar :: Ty ( a) , TyOrConstInferVar :: Ty ( b) ] ;
583
593
ProcessResult :: Unchanged
584
594
}
585
- Ok ( Ok ( ok) ) => ProcessResult :: Changed ( mk_pending ( ok. obligations ) ) ,
595
+ Ok ( Ok ( ok) ) => {
596
+ ProcessResult :: Changed ( mk_pending ( obligation, ok. obligations ) )
597
+ }
586
598
Ok ( Err ( err) ) => {
587
599
let expected_found = ExpectedFound :: new ( coerce. b , coerce. a ) ;
588
600
ProcessResult :: Error ( FulfillmentErrorCode :: Subtype ( expected_found, err) )
@@ -645,6 +657,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
645
657
)
646
658
{
647
659
return ProcessResult :: Changed ( mk_pending (
660
+ obligation,
648
661
new_obligations. into_obligations ( ) ,
649
662
) ) ;
650
663
}
@@ -659,6 +672,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
659
672
. eq ( DefineOpaqueTypes :: Yes , c1, c2)
660
673
{
661
674
return ProcessResult :: Changed ( mk_pending (
675
+ obligation,
662
676
new_obligations. into_obligations ( ) ,
663
677
) ) ;
664
678
}
@@ -704,9 +718,10 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
704
718
c1,
705
719
c2,
706
720
) {
707
- Ok ( inf_ok) => {
708
- ProcessResult :: Changed ( mk_pending ( inf_ok. into_obligations ( ) ) )
709
- }
721
+ Ok ( inf_ok) => ProcessResult :: Changed ( mk_pending (
722
+ obligation,
723
+ inf_ok. into_obligations ( ) ,
724
+ ) ) ,
710
725
Err ( err) => {
711
726
ProcessResult :: Error ( FulfillmentErrorCode :: ConstEquate (
712
727
ExpectedFound :: new ( c1, c2) ,
@@ -790,7 +805,7 @@ impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> {
790
805
match self . selcx . poly_select ( & trait_obligation) {
791
806
Ok ( Some ( impl_source) ) => {
792
807
debug ! ( "selecting trait at depth {} yielded Ok(Some)" , obligation. recursion_depth) ;
793
- ProcessResult :: Changed ( mk_pending ( impl_source. nested_obligations ( ) ) )
808
+ ProcessResult :: Changed ( mk_pending ( obligation , impl_source. nested_obligations ( ) ) )
794
809
}
795
810
Ok ( None ) => {
796
811
debug ! ( "selecting trait at depth {} yielded Ok(None)" , obligation. recursion_depth) ;
@@ -854,7 +869,7 @@ impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> {
854
869
}
855
870
856
871
match project:: poly_project_and_unify_term ( & mut self . selcx , & project_obligation) {
857
- ProjectAndUnifyResult :: Holds ( os) => ProcessResult :: Changed ( mk_pending ( os) ) ,
872
+ ProjectAndUnifyResult :: Holds ( os) => ProcessResult :: Changed ( mk_pending ( obligation , os) ) ,
858
873
ProjectAndUnifyResult :: FailedNormalization => {
859
874
stalled_on. clear ( ) ;
860
875
stalled_on. extend ( args_infer_vars (
@@ -868,7 +883,7 @@ impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> {
868
883
let mut obligations = PredicateObligations :: with_capacity ( 1 ) ;
869
884
obligations. push ( project_obligation. with ( tcx, project_obligation. predicate ) ) ;
870
885
871
- ProcessResult :: Changed ( mk_pending ( obligations) )
886
+ ProcessResult :: Changed ( mk_pending ( obligation , obligations) )
872
887
}
873
888
ProjectAndUnifyResult :: MismatchedProjectionTypes ( e) => {
874
889
ProcessResult :: Error ( FulfillmentErrorCode :: Project ( e) )
@@ -878,11 +893,12 @@ impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> {
878
893
879
894
fn process_host_obligation (
880
895
& mut self ,
896
+ obligation : & PredicateObligation < ' tcx > ,
881
897
host_obligation : HostEffectObligation < ' tcx > ,
882
898
stalled_on : & mut Vec < TyOrConstInferVar > ,
883
899
) -> ProcessResult < PendingPredicateObligation < ' tcx > , FulfillmentErrorCode < ' tcx > > {
884
900
match effects:: evaluate_host_effect_obligation ( & mut self . selcx , & host_obligation) {
885
- Ok ( nested) => ProcessResult :: Changed ( mk_pending ( nested) ) ,
901
+ Ok ( nested) => ProcessResult :: Changed ( mk_pending ( obligation , nested) ) ,
886
902
Err ( effects:: EvaluationFailure :: Ambiguous ) => {
887
903
stalled_on. clear ( ) ;
888
904
stalled_on. extend ( args_infer_vars (
0 commit comments