@@ -741,11 +741,7 @@ fn project_type<'cx, 'tcx>(
741741 return Err ( ProjectionTyError :: TraitSelectionError ( SelectionError :: Overflow ) ) ;
742742 }
743743
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 ( ) {
749745 return Ok ( ProjectedTy :: Progress ( Progress :: error ( selcx. tcx ( ) ) ) ) ;
750746 }
751747
@@ -754,19 +750,19 @@ fn project_type<'cx, 'tcx>(
754750 // Make sure that the following procedures are kept in order. ParamEnv
755751 // needs to be first because it has highest priority, and Select checks
756752 // 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) ;
758754
759- assemble_candidates_from_trait_def ( selcx, obligation, & obligation_trait_ref , & mut candidates) ;
755+ assemble_candidates_from_trait_def ( selcx, obligation, & mut candidates) ;
760756
761- assemble_candidates_from_object_ty ( selcx, obligation, & obligation_trait_ref , & mut candidates) ;
757+ assemble_candidates_from_object_ty ( selcx, obligation, & mut candidates) ;
762758
763759 if let ProjectionTyCandidateSet :: Single ( ProjectionTyCandidate :: Object ( _) ) = candidates {
764760 // Avoid normalization cycle from selection (see
765761 // `assemble_candidates_from_object_ty`).
766762 // FIXME(lazy_normalization): Lazy normalization should save us from
767- // having to do special case this.
763+ // having to special case this.
768764 } else {
769- assemble_candidates_from_impls ( selcx, obligation, & obligation_trait_ref , & mut candidates) ;
765+ assemble_candidates_from_impls ( selcx, obligation, & mut candidates) ;
770766 } ;
771767
772768 match candidates {
@@ -792,14 +788,12 @@ fn project_type<'cx, 'tcx>(
792788fn assemble_candidates_from_param_env < ' cx , ' tcx > (
793789 selcx : & mut SelectionContext < ' cx , ' tcx > ,
794790 obligation : & ProjectionTyObligation < ' tcx > ,
795- obligation_trait_ref : & ty:: TraitRef < ' tcx > ,
796791 candidate_set : & mut ProjectionTyCandidateSet < ' tcx > ,
797792) {
798793 debug ! ( "assemble_candidates_from_param_env(..)" ) ;
799794 assemble_candidates_from_predicates (
800795 selcx,
801796 obligation,
802- obligation_trait_ref,
803797 candidate_set,
804798 ProjectionTyCandidate :: ParamEnv ,
805799 obligation. param_env . caller_bounds ( ) . iter ( ) ,
@@ -820,15 +814,14 @@ fn assemble_candidates_from_param_env<'cx, 'tcx>(
820814fn assemble_candidates_from_trait_def < ' cx , ' tcx > (
821815 selcx : & mut SelectionContext < ' cx , ' tcx > ,
822816 obligation : & ProjectionTyObligation < ' tcx > ,
823- obligation_trait_ref : & ty:: TraitRef < ' tcx > ,
824817 candidate_set : & mut ProjectionTyCandidateSet < ' tcx > ,
825818) {
826819 debug ! ( "assemble_candidates_from_trait_def(..)" ) ;
827820
828821 let tcx = selcx. tcx ( ) ;
829822 // Check whether the self-type is itself a projection.
830823 // 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 ( ) {
832825 ty:: Projection ( ref data) => tcx. item_bounds ( data. item_def_id ) . subst ( tcx, data. substs ) ,
833826 ty:: Opaque ( def_id, substs) => tcx. item_bounds ( def_id) . subst ( tcx, substs) ,
834827 ty:: Infer ( ty:: TyVar ( _) ) => {
@@ -843,7 +836,6 @@ fn assemble_candidates_from_trait_def<'cx, 'tcx>(
843836 assemble_candidates_from_predicates (
844837 selcx,
845838 obligation,
846- obligation_trait_ref,
847839 candidate_set,
848840 ProjectionTyCandidate :: TraitDef ,
849841 bounds. iter ( ) ,
@@ -863,14 +855,13 @@ fn assemble_candidates_from_trait_def<'cx, 'tcx>(
863855fn assemble_candidates_from_object_ty < ' cx , ' tcx > (
864856 selcx : & mut SelectionContext < ' cx , ' tcx > ,
865857 obligation : & ProjectionTyObligation < ' tcx > ,
866- obligation_trait_ref : & ty:: TraitRef < ' tcx > ,
867858 candidate_set : & mut ProjectionTyCandidateSet < ' tcx > ,
868859) {
869860 debug ! ( "assemble_candidates_from_object_ty(..)" ) ;
870861
871862 let tcx = selcx. tcx ( ) ;
872863
873- let self_ty = obligation_trait_ref . self_ty ( ) ;
864+ let self_ty = obligation . predicate . self_ty ( ) ;
874865 let object_ty = selcx. infcx ( ) . shallow_resolve ( self_ty) ;
875866 let data = match object_ty. kind ( ) {
876867 ty:: Dynamic ( data, ..) => data,
@@ -890,7 +881,6 @@ fn assemble_candidates_from_object_ty<'cx, 'tcx>(
890881 assemble_candidates_from_predicates (
891882 selcx,
892883 obligation,
893- obligation_trait_ref,
894884 candidate_set,
895885 ProjectionTyCandidate :: Object ,
896886 env_predicates,
@@ -901,7 +891,6 @@ fn assemble_candidates_from_object_ty<'cx, 'tcx>(
901891fn assemble_candidates_from_predicates < ' cx , ' tcx > (
902892 selcx : & mut SelectionContext < ' cx , ' tcx > ,
903893 obligation : & ProjectionTyObligation < ' tcx > ,
904- obligation_trait_ref : & ty:: TraitRef < ' tcx > ,
905894 candidate_set : & mut ProjectionTyCandidateSet < ' tcx > ,
906895 ctor : fn ( ty:: PolyProjectionPredicate < ' tcx > ) -> ProjectionTyCandidate < ' tcx > ,
907896 env_predicates : impl Iterator < Item = ty:: Predicate < ' tcx > > ,
@@ -947,14 +936,13 @@ fn assemble_candidates_from_predicates<'cx, 'tcx>(
947936fn assemble_candidates_from_impls < ' cx , ' tcx > (
948937 selcx : & mut SelectionContext < ' cx , ' tcx > ,
949938 obligation : & ProjectionTyObligation < ' tcx > ,
950- obligation_trait_ref : & ty:: TraitRef < ' tcx > ,
951939 candidate_set : & mut ProjectionTyCandidateSet < ' tcx > ,
952940) {
953941 debug ! ( "assemble_candidates_from_impls" ) ;
954942
955943 // If we are resolving `<T as TraitRef<...>>::Item == Type`,
956944 // 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 ( ) ;
958946 let trait_obligation = obligation. with ( poly_trait_ref. to_poly_trait_predicate ( ) ) ;
959947 let _ = selcx. infcx ( ) . commit_if_ok ( |_| {
960948 let impl_source = match selcx. select ( & trait_obligation) {
0 commit comments