@@ -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 ;
@@ -693,12 +693,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
693
693
)
694
694
. map_bound ( |( trait_ref, _) | trait_ref) ;
695
695
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) ?;
702
698
let cause = obligation. derived_cause ( BuiltinDerivedObligation ) ;
703
699
704
700
// Confirm the `type Output: Sized;` bound that is present on `FnOnce`
@@ -764,9 +760,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
764
760
) ;
765
761
766
762
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) ,
770
764
ty:: Binder :: dummy ( trait_ref) ,
771
765
) ?;
772
766
debug ! ( ?trait_ref, ?nested, "coroutine candidate obligations" ) ;
@@ -796,9 +790,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
796
790
) ;
797
791
798
792
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) ,
802
794
ty:: Binder :: dummy ( trait_ref) ,
803
795
) ?;
804
796
debug ! ( ?trait_ref, ?nested, "future candidate obligations" ) ;
@@ -828,9 +820,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
828
820
) ;
829
821
830
822
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) ,
834
824
ty:: Binder :: dummy ( trait_ref) ,
835
825
) ?;
836
826
debug ! ( ?trait_ref, ?nested, "iterator candidate obligations" ) ;
@@ -860,9 +850,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
860
850
) ;
861
851
862
852
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) ,
866
854
ty:: Binder :: dummy ( trait_ref) ,
867
855
) ?;
868
856
debug ! ( ?trait_ref, ?nested, "iterator candidate obligations" ) ;
@@ -898,12 +886,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
898
886
}
899
887
} ;
900
888
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)
907
890
}
908
891
909
892
#[ instrument( skip( self ) , level = "debug" ) ]
@@ -981,12 +964,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
981
964
_ => bug ! ( "expected callable type for AsyncFn candidate" ) ,
982
965
} ;
983
966
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
+ ) ;
990
970
991
971
let goal_kind =
992
972
self . tcx ( ) . async_fn_trait_kind_from_def_id ( obligation. predicate . def_id ( ) ) . unwrap ( ) ;
@@ -1041,13 +1021,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1041
1021
#[ instrument( skip( self ) , level = "trace" ) ]
1042
1022
fn equate_trait_refs (
1043
1023
& mut self ,
1044
- cause : & ObligationCause < ' tcx > ,
1045
- param_env : ty:: ParamEnv < ' tcx > ,
1046
- obligation_trait_ref : ty:: TraitRef < ' tcx > ,
1024
+ obligation : TraitObligation < ' tcx > ,
1047
1025
found_trait_ref : ty:: PolyTraitRef < ' tcx > ,
1048
1026
) -> Result < Vec < PredicateObligation < ' tcx > > , SelectionError < ' tcx > > {
1049
1027
let found_trait_ref = self . infcx . instantiate_binder_with_fresh_vars (
1050
- cause. span ,
1028
+ obligation . cause . span ,
1051
1029
HigherRankedType ,
1052
1030
found_trait_ref,
1053
1031
) ;
@@ -1056,16 +1034,16 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1056
1034
ensure_sufficient_stack ( || {
1057
1035
normalize_with_depth (
1058
1036
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) ,
1063
1041
)
1064
1042
} ) ;
1065
1043
1066
1044
// needed to define opaque types for tests/ui/type-alias-impl-trait/assoc-projection-ice.rs
1067
1045
self . infcx
1068
- . at ( & cause, param_env)
1046
+ . at ( & obligation . cause , obligation . param_env )
1069
1047
. eq ( DefineOpaqueTypes :: Yes , obligation_trait_ref, found_trait_ref)
1070
1048
. map ( |InferOk { mut obligations, .. } | {
1071
1049
obligations. extend ( nested) ;
0 commit comments