@@ -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 ;
@@ -691,12 +691,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
691691 )
692692 . map_bound ( |( trait_ref, _) | trait_ref) ;
693693
694- let mut nested = self . equate_trait_refs (
695- & obligation. cause ,
696- obligation. param_env ,
697- placeholder_predicate. trait_ref ,
698- trait_ref,
699- ) ?;
694+ let mut nested =
695+ self . equate_trait_refs ( obligation. with ( tcx, placeholder_predicate) , trait_ref) ?;
700696 let cause = obligation. derived_cause ( BuiltinDerivedObligation ) ;
701697
702698 // Confirm the `type Output: Sized;` bound that is present on `FnOnce`
@@ -762,9 +758,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
762758 ) ;
763759
764760 let nested = self . equate_trait_refs (
765- & obligation. cause ,
766- obligation. param_env ,
767- placeholder_predicate. trait_ref ,
761+ obligation. with ( self . tcx ( ) , placeholder_predicate) ,
768762 ty:: Binder :: dummy ( trait_ref) ,
769763 ) ?;
770764 debug ! ( ?trait_ref, ?nested, "coroutine candidate obligations" ) ;
@@ -794,9 +788,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
794788 ) ;
795789
796790 let nested = self . equate_trait_refs (
797- & obligation. cause ,
798- obligation. param_env ,
799- placeholder_predicate. trait_ref ,
791+ obligation. with ( self . tcx ( ) , placeholder_predicate) ,
800792 ty:: Binder :: dummy ( trait_ref) ,
801793 ) ?;
802794 debug ! ( ?trait_ref, ?nested, "future candidate obligations" ) ;
@@ -826,9 +818,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
826818 ) ;
827819
828820 let nested = self . equate_trait_refs (
829- & obligation. cause ,
830- obligation. param_env ,
831- placeholder_predicate. trait_ref ,
821+ obligation. with ( self . tcx ( ) , placeholder_predicate) ,
832822 ty:: Binder :: dummy ( trait_ref) ,
833823 ) ?;
834824 debug ! ( ?trait_ref, ?nested, "iterator candidate obligations" ) ;
@@ -858,9 +848,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
858848 ) ;
859849
860850 let nested = self . equate_trait_refs (
861- & obligation. cause ,
862- obligation. param_env ,
863- placeholder_predicate. trait_ref ,
851+ obligation. with ( self . tcx ( ) , placeholder_predicate) ,
864852 ty:: Binder :: dummy ( trait_ref) ,
865853 ) ?;
866854 debug ! ( ?trait_ref, ?nested, "iterator candidate obligations" ) ;
@@ -896,12 +884,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
896884 }
897885 } ;
898886
899- self . equate_trait_refs (
900- & obligation. cause ,
901- obligation. param_env ,
902- placeholder_predicate. trait_ref ,
903- trait_ref,
904- )
887+ self . equate_trait_refs ( obligation. with ( self . tcx ( ) , placeholder_predicate) , trait_ref)
905888 }
906889
907890 #[ instrument( skip( self ) , level = "debug" ) ]
@@ -979,12 +962,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
979962 _ => bug ! ( "expected callable type for AsyncFn candidate" ) ,
980963 } ;
981964
982- nested. extend ( self . equate_trait_refs (
983- & obligation. cause ,
984- obligation. param_env ,
985- placeholder_predicate. trait_ref ,
986- trait_ref,
987- ) ?) ;
965+ nested. extend (
966+ self . equate_trait_refs ( obligation. with ( tcx, placeholder_predicate) , trait_ref) ?,
967+ ) ;
988968
989969 let goal_kind =
990970 self . tcx ( ) . async_fn_trait_kind_from_def_id ( obligation. predicate . def_id ( ) ) . unwrap ( ) ;
@@ -1039,13 +1019,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10391019 #[ instrument( skip( self ) , level = "trace" ) ]
10401020 fn equate_trait_refs (
10411021 & mut self ,
1042- cause : & ObligationCause < ' tcx > ,
1043- param_env : ty:: ParamEnv < ' tcx > ,
1044- obligation_trait_ref : ty:: TraitRef < ' tcx > ,
1022+ obligation : TraitObligation < ' tcx > ,
10451023 found_trait_ref : ty:: PolyTraitRef < ' tcx > ,
10461024 ) -> Result < Vec < PredicateObligation < ' tcx > > , SelectionError < ' tcx > > {
10471025 let found_trait_ref = self . infcx . instantiate_binder_with_fresh_vars (
1048- cause. span ,
1026+ obligation . cause . span ,
10491027 HigherRankedType ,
10501028 found_trait_ref,
10511029 ) ;
@@ -1054,16 +1032,16 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10541032 ensure_sufficient_stack ( || {
10551033 normalize_with_depth (
10561034 self ,
1057- param_env,
1058- cause. clone ( ) ,
1059- 0 ,
1060- ( obligation_trait_ref , found_trait_ref) ,
1035+ obligation . param_env ,
1036+ obligation . cause . clone ( ) ,
1037+ obligation . recursion_depth + 1 ,
1038+ ( obligation . predicate . trait_ref , found_trait_ref) ,
10611039 )
10621040 } ) ;
10631041
10641042 // needed to define opaque types for tests/ui/type-alias-impl-trait/assoc-projection-ice.rs
10651043 self . infcx
1066- . at ( & cause, param_env)
1044+ . at ( & obligation . cause , obligation . param_env )
10671045 . eq ( DefineOpaqueTypes :: Yes , obligation_trait_ref, found_trait_ref)
10681046 . map ( |InferOk { mut obligations, .. } | {
10691047 obligations. extend ( nested) ;
0 commit comments