@@ -28,7 +28,7 @@ use crate::traits::{
2828 BuiltinDerivedObligation , ImplDerivedObligation , ImplDerivedObligationCause , ImplSource ,
2929 ImplSourceUserDefinedData , Normalized , Obligation , ObligationCause , PolyTraitObligation ,
3030 PredicateObligation , Selection , SelectionError , SignatureMismatch , TraitNotObjectSafe ,
31- Unimplemented ,
31+ TraitObligation , Unimplemented ,
3232} ;
3333
3434use super :: BuiltinImplConditions ;
@@ -693,12 +693,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
693693 )
694694 . map_bound ( |( trait_ref, _) | trait_ref) ;
695695
696- let mut nested = self . equate_trait_refs (
697- & obligation. cause ,
698- obligation. param_env ,
699- placeholder_predicate. trait_ref ,
700- trait_ref,
701- ) ?;
696+ let mut nested =
697+ self . equate_trait_refs ( obligation. with ( tcx, placeholder_predicate) , trait_ref) ?;
702698 let cause = obligation. derived_cause ( BuiltinDerivedObligation ) ;
703699
704700 // Confirm the `type Output: Sized;` bound that is present on `FnOnce`
@@ -764,9 +760,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
764760 ) ;
765761
766762 let nested = self . equate_trait_refs (
767- & obligation. cause ,
768- obligation. param_env ,
769- placeholder_predicate. trait_ref ,
763+ obligation. with ( self . tcx ( ) , placeholder_predicate) ,
770764 ty:: Binder :: dummy ( trait_ref) ,
771765 ) ?;
772766 debug ! ( ?trait_ref, ?nested, "coroutine candidate obligations" ) ;
@@ -796,9 +790,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
796790 ) ;
797791
798792 let nested = self . equate_trait_refs (
799- & obligation. cause ,
800- obligation. param_env ,
801- placeholder_predicate. trait_ref ,
793+ obligation. with ( self . tcx ( ) , placeholder_predicate) ,
802794 ty:: Binder :: dummy ( trait_ref) ,
803795 ) ?;
804796 debug ! ( ?trait_ref, ?nested, "future candidate obligations" ) ;
@@ -828,9 +820,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
828820 ) ;
829821
830822 let nested = self . equate_trait_refs (
831- & obligation. cause ,
832- obligation. param_env ,
833- placeholder_predicate. trait_ref ,
823+ obligation. with ( self . tcx ( ) , placeholder_predicate) ,
834824 ty:: Binder :: dummy ( trait_ref) ,
835825 ) ?;
836826 debug ! ( ?trait_ref, ?nested, "iterator candidate obligations" ) ;
@@ -860,9 +850,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
860850 ) ;
861851
862852 let nested = self . equate_trait_refs (
863- & obligation. cause ,
864- obligation. param_env ,
865- placeholder_predicate. trait_ref ,
853+ obligation. with ( self . tcx ( ) , placeholder_predicate) ,
866854 ty:: Binder :: dummy ( trait_ref) ,
867855 ) ?;
868856 debug ! ( ?trait_ref, ?nested, "iterator candidate obligations" ) ;
@@ -898,12 +886,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
898886 }
899887 } ;
900888
901- self . equate_trait_refs (
902- & obligation. cause ,
903- obligation. param_env ,
904- placeholder_predicate. trait_ref ,
905- trait_ref,
906- )
889+ self . equate_trait_refs ( obligation. with ( self . tcx ( ) , placeholder_predicate) , trait_ref)
907890 }
908891
909892 #[ instrument( skip( self ) , level = "debug" ) ]
@@ -981,12 +964,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
981964 _ => bug ! ( "expected callable type for AsyncFn candidate" ) ,
982965 } ;
983966
984- nested. extend ( self . equate_trait_refs (
985- & obligation. cause ,
986- obligation. param_env ,
987- placeholder_predicate. trait_ref ,
988- trait_ref,
989- ) ?) ;
967+ nested. extend (
968+ self . equate_trait_refs ( obligation. with ( tcx, placeholder_predicate) , trait_ref) ?,
969+ ) ;
990970
991971 let goal_kind =
992972 self . tcx ( ) . async_fn_trait_kind_from_def_id ( obligation. predicate . def_id ( ) ) . unwrap ( ) ;
@@ -1041,13 +1021,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10411021 #[ instrument( skip( self ) , level = "trace" ) ]
10421022 fn equate_trait_refs (
10431023 & mut self ,
1044- cause : & ObligationCause < ' tcx > ,
1045- param_env : ty:: ParamEnv < ' tcx > ,
1046- obligation_trait_ref : ty:: TraitRef < ' tcx > ,
1024+ obligation : TraitObligation < ' tcx > ,
10471025 found_trait_ref : ty:: PolyTraitRef < ' tcx > ,
10481026 ) -> Result < Vec < PredicateObligation < ' tcx > > , SelectionError < ' tcx > > {
10491027 let found_trait_ref = self . infcx . instantiate_binder_with_fresh_vars (
1050- cause. span ,
1028+ obligation . cause . span ,
10511029 HigherRankedType ,
10521030 found_trait_ref,
10531031 ) ;
@@ -1056,16 +1034,16 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10561034 ensure_sufficient_stack ( || {
10571035 normalize_with_depth (
10581036 self ,
1059- param_env,
1060- cause. clone ( ) ,
1061- 0 ,
1062- ( obligation_trait_ref , found_trait_ref) ,
1037+ obligation . param_env ,
1038+ obligation . cause . clone ( ) ,
1039+ obligation . recursion_depth + 1 ,
1040+ ( obligation . predicate . trait_ref , found_trait_ref) ,
10631041 )
10641042 } ) ;
10651043
10661044 // needed to define opaque types for tests/ui/type-alias-impl-trait/assoc-projection-ice.rs
10671045 self . infcx
1068- . at ( & cause, param_env)
1046+ . at ( & obligation . cause , obligation . param_env )
10691047 . eq ( DefineOpaqueTypes :: Yes , obligation_trait_ref, found_trait_ref)
10701048 . map ( |InferOk { mut obligations, .. } | {
10711049 obligations. extend ( nested) ;
0 commit comments