@@ -741,11 +741,7 @@ fn project_type<'cx, 'tcx>(
741
741
return Err ( ProjectionTyError :: TraitSelectionError ( SelectionError :: Overflow ) ) ;
742
742
}
743
743
744
- let obligation_trait_ref = & obligation. predicate . trait_ref ( selcx. tcx ( ) ) ;
745
-
746
- debug ! ( ?obligation_trait_ref) ;
747
-
748
- if obligation_trait_ref. references_error ( ) {
744
+ if obligation. predicate . references_error ( ) {
749
745
return Ok ( ProjectedTy :: Progress ( Progress :: error ( selcx. tcx ( ) ) ) ) ;
750
746
}
751
747
@@ -754,19 +750,19 @@ fn project_type<'cx, 'tcx>(
754
750
// Make sure that the following procedures are kept in order. ParamEnv
755
751
// needs to be first because it has highest priority, and Select checks
756
752
// the return value of push_candidate which assumes it's ran at last.
757
- assemble_candidates_from_param_env ( selcx, obligation, & obligation_trait_ref , & mut candidates) ;
753
+ assemble_candidates_from_param_env ( selcx, obligation, & mut candidates) ;
758
754
759
- assemble_candidates_from_trait_def ( selcx, obligation, & obligation_trait_ref , & mut candidates) ;
755
+ assemble_candidates_from_trait_def ( selcx, obligation, & mut candidates) ;
760
756
761
- assemble_candidates_from_object_ty ( selcx, obligation, & obligation_trait_ref , & mut candidates) ;
757
+ assemble_candidates_from_object_ty ( selcx, obligation, & mut candidates) ;
762
758
763
759
if let ProjectionTyCandidateSet :: Single ( ProjectionTyCandidate :: Object ( _) ) = candidates {
764
760
// Avoid normalization cycle from selection (see
765
761
// `assemble_candidates_from_object_ty`).
766
762
// FIXME(lazy_normalization): Lazy normalization should save us from
767
- // having to do special case this.
763
+ // having to special case this.
768
764
} else {
769
- assemble_candidates_from_impls ( selcx, obligation, & obligation_trait_ref , & mut candidates) ;
765
+ assemble_candidates_from_impls ( selcx, obligation, & mut candidates) ;
770
766
} ;
771
767
772
768
match candidates {
@@ -792,14 +788,12 @@ fn project_type<'cx, 'tcx>(
792
788
fn assemble_candidates_from_param_env < ' cx , ' tcx > (
793
789
selcx : & mut SelectionContext < ' cx , ' tcx > ,
794
790
obligation : & ProjectionTyObligation < ' tcx > ,
795
- obligation_trait_ref : & ty:: TraitRef < ' tcx > ,
796
791
candidate_set : & mut ProjectionTyCandidateSet < ' tcx > ,
797
792
) {
798
793
debug ! ( "assemble_candidates_from_param_env(..)" ) ;
799
794
assemble_candidates_from_predicates (
800
795
selcx,
801
796
obligation,
802
- obligation_trait_ref,
803
797
candidate_set,
804
798
ProjectionTyCandidate :: ParamEnv ,
805
799
obligation. param_env . caller_bounds ( ) . iter ( ) ,
@@ -820,15 +814,14 @@ fn assemble_candidates_from_param_env<'cx, 'tcx>(
820
814
fn assemble_candidates_from_trait_def < ' cx , ' tcx > (
821
815
selcx : & mut SelectionContext < ' cx , ' tcx > ,
822
816
obligation : & ProjectionTyObligation < ' tcx > ,
823
- obligation_trait_ref : & ty:: TraitRef < ' tcx > ,
824
817
candidate_set : & mut ProjectionTyCandidateSet < ' tcx > ,
825
818
) {
826
819
debug ! ( "assemble_candidates_from_trait_def(..)" ) ;
827
820
828
821
let tcx = selcx. tcx ( ) ;
829
822
// Check whether the self-type is itself a projection.
830
823
// If so, extract what we know from the trait and try to come up with a good answer.
831
- let bounds = match * obligation_trait_ref . self_ty ( ) . kind ( ) {
824
+ let bounds = match * obligation . predicate . self_ty ( ) . kind ( ) {
832
825
ty:: Projection ( ref data) => tcx. item_bounds ( data. item_def_id ) . subst ( tcx, data. substs ) ,
833
826
ty:: Opaque ( def_id, substs) => tcx. item_bounds ( def_id) . subst ( tcx, substs) ,
834
827
ty:: Infer ( ty:: TyVar ( _) ) => {
@@ -843,7 +836,6 @@ fn assemble_candidates_from_trait_def<'cx, 'tcx>(
843
836
assemble_candidates_from_predicates (
844
837
selcx,
845
838
obligation,
846
- obligation_trait_ref,
847
839
candidate_set,
848
840
ProjectionTyCandidate :: TraitDef ,
849
841
bounds. iter ( ) ,
@@ -863,14 +855,13 @@ fn assemble_candidates_from_trait_def<'cx, 'tcx>(
863
855
fn assemble_candidates_from_object_ty < ' cx , ' tcx > (
864
856
selcx : & mut SelectionContext < ' cx , ' tcx > ,
865
857
obligation : & ProjectionTyObligation < ' tcx > ,
866
- obligation_trait_ref : & ty:: TraitRef < ' tcx > ,
867
858
candidate_set : & mut ProjectionTyCandidateSet < ' tcx > ,
868
859
) {
869
860
debug ! ( "assemble_candidates_from_object_ty(..)" ) ;
870
861
871
862
let tcx = selcx. tcx ( ) ;
872
863
873
- let self_ty = obligation_trait_ref . self_ty ( ) ;
864
+ let self_ty = obligation . predicate . self_ty ( ) ;
874
865
let object_ty = selcx. infcx ( ) . shallow_resolve ( self_ty) ;
875
866
let data = match object_ty. kind ( ) {
876
867
ty:: Dynamic ( data, ..) => data,
@@ -890,7 +881,6 @@ fn assemble_candidates_from_object_ty<'cx, 'tcx>(
890
881
assemble_candidates_from_predicates (
891
882
selcx,
892
883
obligation,
893
- obligation_trait_ref,
894
884
candidate_set,
895
885
ProjectionTyCandidate :: Object ,
896
886
env_predicates,
@@ -901,7 +891,6 @@ fn assemble_candidates_from_object_ty<'cx, 'tcx>(
901
891
fn assemble_candidates_from_predicates < ' cx , ' tcx > (
902
892
selcx : & mut SelectionContext < ' cx , ' tcx > ,
903
893
obligation : & ProjectionTyObligation < ' tcx > ,
904
- obligation_trait_ref : & ty:: TraitRef < ' tcx > ,
905
894
candidate_set : & mut ProjectionTyCandidateSet < ' tcx > ,
906
895
ctor : fn ( ty:: PolyProjectionPredicate < ' tcx > ) -> ProjectionTyCandidate < ' tcx > ,
907
896
env_predicates : impl Iterator < Item = ty:: Predicate < ' tcx > > ,
@@ -947,14 +936,13 @@ fn assemble_candidates_from_predicates<'cx, 'tcx>(
947
936
fn assemble_candidates_from_impls < ' cx , ' tcx > (
948
937
selcx : & mut SelectionContext < ' cx , ' tcx > ,
949
938
obligation : & ProjectionTyObligation < ' tcx > ,
950
- obligation_trait_ref : & ty:: TraitRef < ' tcx > ,
951
939
candidate_set : & mut ProjectionTyCandidateSet < ' tcx > ,
952
940
) {
953
941
debug ! ( "assemble_candidates_from_impls" ) ;
954
942
955
943
// If we are resolving `<T as TraitRef<...>>::Item == Type`,
956
944
// start out by selecting the predicate `T as TraitRef<...>`:
957
- let poly_trait_ref = ty :: Binder :: dummy ( * obligation_trait_ref ) ;
945
+ let poly_trait_ref = obligation . predicate . trait_ref ( selcx . tcx ( ) ) . to_poly_trait_ref ( ) ;
958
946
let trait_obligation = obligation. with ( poly_trait_ref. to_poly_trait_predicate ( ) ) ;
959
947
let _ = selcx. infcx ( ) . commit_if_ok ( |_| {
960
948
let impl_source = match selcx. select ( & trait_obligation) {
0 commit comments