@@ -260,15 +260,9 @@ struct FulfillProcessor<'a, 'b, 'tcx> {
260
260
register_region_obligations : bool ,
261
261
}
262
262
263
- fn mk_pending (
264
- infcx : & InferCtxt < ' _ , ' tcx > ,
265
- os : Vec < PredicateObligation < ' tcx > > ,
266
- ) -> Vec < PendingPredicateObligation < ' tcx > > {
263
+ fn mk_pending ( os : Vec < PredicateObligation < ' tcx > > ) -> Vec < PendingPredicateObligation < ' tcx > > {
267
264
os. into_iter ( )
268
- . map ( |mut o| {
269
- o. predicate = infcx. resolve_vars_if_possible ( & o. predicate ) ;
270
- PendingPredicateObligation { obligation : o, stalled_on : vec ! [ ] }
271
- } )
265
+ . map ( |o| PendingPredicateObligation { obligation : o, stalled_on : vec ! [ ] } )
272
266
. collect ( )
273
267
}
274
268
@@ -412,29 +406,38 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
412
406
) {
413
407
None => {
414
408
pending_obligation. stalled_on . clear ( ) ;
415
- pending_obligation. stalled_on . push ( TyOrConstInferVar :: maybe_from_generic_arg ( arg) . unwrap ( ) ) ;
409
+ pending_obligation. stalled_on . push ( infcx. root_ty_or_const (
410
+ TyOrConstInferVar :: maybe_from_generic_arg ( arg) . unwrap ( ) ,
411
+ ) ) ;
416
412
ProcessResult :: Unchanged
417
413
}
418
414
Some ( os) => ProcessResult :: Changed ( mk_pending ( os) ) ,
419
415
}
420
416
}
421
417
422
- & ty:: PredicateKind :: WellFormed ( arg) => {
423
- match wf:: obligations (
424
- self . selcx . infcx ( ) ,
425
- obligation. param_env ,
426
- obligation. cause . body_id ,
427
- arg,
428
- obligation. cause . span ,
429
- ) {
430
- None => {
431
- pending_obligation. stalled_on . clear ( ) ;
432
- pending_obligation
433
- . stalled_on
434
- . push ( TyOrConstInferVar :: maybe_from_generic_arg ( arg) . unwrap ( ) ) ;
435
- ProcessResult :: Unchanged
418
+ ty:: PredicateAtom :: Subtype ( subtype) => {
419
+ match self . selcx . infcx ( ) . subtype_predicate (
420
+ & obligation. cause ,
421
+ obligation. param_env ,
422
+ Binder :: dummy ( subtype) ,
423
+ ) {
424
+ None => {
425
+ // None means that both are unresolved.
426
+ pending_obligation. stalled_on . clear ( ) ;
427
+ pending_obligation. stalled_on . push ( root_ty_or_const_var ( subtype. a ) ) ;
428
+ pending_obligation. stalled_on . push ( root_ty_or_const_var ( subtype. b ) ) ;
429
+ ProcessResult :: Unchanged
430
+ }
431
+ Some ( Ok ( ok) ) => ProcessResult :: Changed ( mk_pending ( ok. obligations ) ) ,
432
+ Some ( Err ( err) ) => {
433
+ let expected_found =
434
+ ExpectedFound :: new ( subtype. a_is_expected , subtype. a , subtype. b ) ;
435
+ ProcessResult :: Error ( FulfillmentErrorCode :: CodeSubtypeError (
436
+ expected_found,
437
+ err,
438
+ ) )
439
+ }
436
440
}
437
- Some ( os) => ProcessResult :: Changed ( mk_pending ( infcx, os) ) ,
438
441
}
439
442
440
443
ty:: PredicateAtom :: ConstEvaluatable ( def_id, substs) => {
@@ -447,10 +450,12 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
447
450
) {
448
451
Ok ( ( ) ) => ProcessResult :: Changed ( vec ! [ ] ) ,
449
452
Err ( ErrorHandled :: TooGeneric ) => {
450
- pending_obligation. stalled_on = substs
451
- . iter ( )
452
- . filter_map ( |ty| TyOrConstInferVar :: maybe_from_generic_arg ( ty) )
453
- . collect ( ) ;
453
+ pending_obligation. stalled_on . extend (
454
+ substs
455
+ . iter ( )
456
+ . filter_map ( |ty| TyOrConstInferVar :: maybe_from_generic_arg ( ty) )
457
+ . map ( |ty| infcx. root_ty_or_const ( ty) ) ,
458
+ ) ;
454
459
ProcessResult :: Unchanged
455
460
}
456
461
Err ( e) => ProcessResult :: Error ( CodeSelectionError ( ConstEvalFailure ( e) ) ) ,
@@ -492,13 +497,13 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
492
497
) {
493
498
Ok ( val) => Ok ( Const :: from_value ( self . selcx . tcx ( ) , val, c. ty ) ) ,
494
499
Err ( ErrorHandled :: TooGeneric ) => {
495
- stalled_on. append (
496
- & mut substs
497
- . iter ( )
500
+ stalled_on. extend (
501
+ substs
502
+ . types ( )
498
503
. filter_map ( |arg| {
499
504
TyOrConstInferVar :: maybe_from_generic_arg ( arg)
500
505
} )
501
- . collect ( ) ,
506
+ . map ( |ty| infcx . root_ty_or_const ( ty ) ) ,
502
507
) ;
503
508
Err ( ErrorHandled :: TooGeneric )
504
509
}
@@ -596,7 +601,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
596
601
& mut self ,
597
602
obligation : & PredicateObligation < ' tcx > ,
598
603
trait_obligation : TraitObligation < ' tcx > ,
599
- stalled_on: & mut Vec < TyOrConstInferVar < ' tcx > > ,
604
+ stalled_on : & mut Vec < TyOrConstInferVar > ,
600
605
) -> ProcessResult < PendingPredicateObligation < ' tcx > , FulfillmentErrorCode < ' tcx > > {
601
606
let infcx = self . selcx . infcx ( ) ;
602
607
if obligation. predicate . is_global ( ) {
@@ -623,10 +628,10 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
623
628
// only reason we can fail to make progress on
624
629
// trait selection is because we don't have enough
625
630
// information about the types in the trait.
626
- * stalled_on = trait_ref_infer_vars(
631
+ stalled_on. extend ( trait_ref_infer_vars (
627
632
self . selcx ,
628
633
trait_obligation. predicate . map_bound ( |pred| pred. trait_ref ) ,
629
- ) ;
634
+ ) ) ;
630
635
631
636
debug ! (
632
637
"process_predicate: pending obligation {:?} now stalled on {:?}" ,
@@ -647,16 +652,16 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
647
652
fn process_projection_obligation (
648
653
& mut self ,
649
654
project_obligation : PolyProjectionObligation < ' tcx > ,
650
- stalled_on: & mut Vec < TyOrConstInferVar < ' tcx > > ,
655
+ stalled_on : & mut Vec < TyOrConstInferVar > ,
651
656
) -> ProcessResult < PendingPredicateObligation < ' tcx > , FulfillmentErrorCode < ' tcx > > {
652
657
let tcx = self . selcx . tcx ( ) ;
653
658
match project:: poly_project_and_unify_type ( self . selcx , & project_obligation) {
654
659
Ok ( Ok ( Some ( os) ) ) => ProcessResult :: Changed ( mk_pending ( os) ) ,
655
660
Ok ( Ok ( None ) ) => {
656
- * stalled_on = trait_ref_infer_vars(
661
+ stalled_on. extend ( trait_ref_infer_vars (
657
662
self . selcx ,
658
663
project_obligation. predicate . to_poly_trait_ref ( tcx) ,
659
- ) ;
664
+ ) ) ;
660
665
ProcessResult :: Unchanged
661
666
}
662
667
// Let the caller handle the recursion
0 commit comments