@@ -28,7 +28,7 @@ use crate::traits::{
28
28
BuiltinDerivedObligation , ImplDerivedObligation , ImplDerivedObligationCause , ImplSource ,
29
29
ImplSourceUserDefinedData , Normalized , Obligation , ObligationCause , PolyTraitObligation ,
30
30
PredicateObligation , Selection , SelectionError , SignatureMismatch , TraitNotObjectSafe ,
31
- Unimplemented ,
31
+ TraitObligation , Unimplemented ,
32
32
} ;
33
33
34
34
use super :: BuiltinImplConditions ;
@@ -691,12 +691,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
691
691
)
692
692
. map_bound ( |( trait_ref, _) | trait_ref) ;
693
693
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) ?;
700
696
let cause = obligation. derived_cause ( BuiltinDerivedObligation ) ;
701
697
702
698
// Confirm the `type Output: Sized;` bound that is present on `FnOnce`
@@ -762,9 +758,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
762
758
) ;
763
759
764
760
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) ,
768
762
ty:: Binder :: dummy ( trait_ref) ,
769
763
) ?;
770
764
debug ! ( ?trait_ref, ?nested, "coroutine candidate obligations" ) ;
@@ -794,9 +788,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
794
788
) ;
795
789
796
790
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) ,
800
792
ty:: Binder :: dummy ( trait_ref) ,
801
793
) ?;
802
794
debug ! ( ?trait_ref, ?nested, "future candidate obligations" ) ;
@@ -826,9 +818,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
826
818
) ;
827
819
828
820
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) ,
832
822
ty:: Binder :: dummy ( trait_ref) ,
833
823
) ?;
834
824
debug ! ( ?trait_ref, ?nested, "iterator candidate obligations" ) ;
@@ -858,9 +848,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
858
848
) ;
859
849
860
850
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) ,
864
852
ty:: Binder :: dummy ( trait_ref) ,
865
853
) ?;
866
854
debug ! ( ?trait_ref, ?nested, "iterator candidate obligations" ) ;
@@ -896,12 +884,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
896
884
}
897
885
} ;
898
886
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)
905
888
}
906
889
907
890
#[ instrument( skip( self ) , level = "debug" ) ]
@@ -979,12 +962,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
979
962
_ => bug ! ( "expected callable type for AsyncFn candidate" ) ,
980
963
} ;
981
964
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
+ ) ;
988
968
989
969
let goal_kind =
990
970
self . tcx ( ) . async_fn_trait_kind_from_def_id ( obligation. predicate . def_id ( ) ) . unwrap ( ) ;
@@ -1039,13 +1019,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1039
1019
#[ instrument( skip( self ) , level = "trace" ) ]
1040
1020
fn equate_trait_refs (
1041
1021
& mut self ,
1042
- cause : & ObligationCause < ' tcx > ,
1043
- param_env : ty:: ParamEnv < ' tcx > ,
1044
- obligation_trait_ref : ty:: TraitRef < ' tcx > ,
1022
+ obligation : TraitObligation < ' tcx > ,
1045
1023
found_trait_ref : ty:: PolyTraitRef < ' tcx > ,
1046
1024
) -> Result < Vec < PredicateObligation < ' tcx > > , SelectionError < ' tcx > > {
1047
1025
let found_trait_ref = self . infcx . instantiate_binder_with_fresh_vars (
1048
- cause. span ,
1026
+ obligation . cause . span ,
1049
1027
HigherRankedType ,
1050
1028
found_trait_ref,
1051
1029
) ;
@@ -1054,16 +1032,16 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1054
1032
ensure_sufficient_stack ( || {
1055
1033
normalize_with_depth (
1056
1034
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) ,
1061
1039
)
1062
1040
} ) ;
1063
1041
1064
1042
// needed to define opaque types for tests/ui/type-alias-impl-trait/assoc-projection-ice.rs
1065
1043
self . infcx
1066
- . at ( & cause, param_env)
1044
+ . at ( & obligation . cause , obligation . param_env )
1067
1045
. eq ( DefineOpaqueTypes :: Yes , obligation_trait_ref, found_trait_ref)
1068
1046
. map ( |InferOk { mut obligations, .. } | {
1069
1047
obligations. extend ( nested) ;
0 commit comments