@@ -644,8 +644,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
644644 // This suffices to allow chains like `FnMut` implemented in
645645 // terms of `Fn` etc, but we could probably make this more
646646 // precise still.
647- let input_types = stack. fresh_trait_ref . 0 . input_types ( ) ;
648- let unbound_input_types = input_types. iter ( ) . any ( |ty| ty. is_fresh ( ) ) ;
647+ let unbound_input_types = stack. fresh_trait_ref . input_types ( ) . any ( |ty| ty. is_fresh ( ) ) ;
649648 if unbound_input_types && self . intercrate {
650649 debug ! ( "evaluate_stack({:?}) --> unbound argument, intercrate --> ambiguous" ,
651650 stack. fresh_trait_ref) ;
@@ -1064,9 +1063,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
10641063
10651064 match * candidate {
10661065 Ok ( Some ( _) ) | Err ( _) => true ,
1067- Ok ( None ) => {
1068- cache_fresh_trait_pred. 0 . trait_ref . substs . types . has_infer_types ( )
1069- }
1066+ Ok ( None ) => cache_fresh_trait_pred. has_infer_types ( )
10701067 }
10711068 }
10721069
@@ -1603,7 +1600,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
16031600 return ;
16041601 }
16051602 } ;
1606- let target = obligation. predicate . skip_binder ( ) . input_types ( ) [ 1 ] ;
1603+ let target = obligation. predicate . skip_binder ( ) . trait_ref . substs . type_at ( 1 ) ;
16071604
16081605 debug ! ( "assemble_candidates_for_unsizing(source={:?}, target={:?})" ,
16091606 source, target) ;
@@ -1936,7 +1933,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
19361933
19371934 // for `PhantomData<T>`, we pass `T`
19381935 ty:: TyStruct ( def, substs) if def. is_phantom_data ( ) => {
1939- substs. types . to_vec ( )
1936+ substs. types ( ) . cloned ( ) . collect ( )
19401937 }
19411938
19421939 ty:: TyStruct ( def, substs) | ty:: TyEnum ( def, substs) => {
@@ -2180,12 +2177,12 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
21802177 match self_ty. sty {
21812178 ty:: TyTrait ( ref data) => {
21822179 // OK to skip the binder, it is reintroduced below
2183- let input_types = data. principal . skip_binder ( ) . input_types ( ) ;
2180+ let input_types = data. principal . input_types ( ) ;
21842181 let assoc_types = data. projection_bounds . iter ( )
21852182 . map ( |pb| pb. skip_binder ( ) . ty ) ;
2186- let all_types: Vec < _ > = input_types. iter ( ) . cloned ( )
2187- . chain ( assoc_types)
2188- . collect ( ) ;
2183+ let all_types: Vec < _ > = input_types. cloned ( )
2184+ . chain ( assoc_types)
2185+ . collect ( ) ;
21892186
21902187 // reintroduce the two binding levels we skipped, then flatten into one
21912188 let all_types = ty:: Binder ( ty:: Binder ( all_types) ) ;
@@ -2476,7 +2473,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
24762473 // regions here. See the comment there for more details.
24772474 let source = self . infcx . shallow_resolve (
24782475 tcx. no_late_bound_regions ( & obligation. self_ty ( ) ) . unwrap ( ) ) ;
2479- let target = obligation. predicate . skip_binder ( ) . input_types ( ) [ 1 ] ;
2476+ let target = obligation. predicate . skip_binder ( ) . trait_ref . substs . type_at ( 1 ) ;
24802477 let target = self . infcx . shallow_resolve ( target) ;
24812478
24822479 debug ! ( "confirm_builtin_unsize_candidate(source={:?}, target={:?})" ,
@@ -2585,7 +2582,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
25852582 } else {
25862583 return Err ( Unimplemented ) ;
25872584 } ;
2588- let mut ty_params = BitVector :: new ( substs_a. types . len ( ) ) ;
2585+ let mut ty_params = BitVector :: new ( substs_a. types ( ) . count ( ) ) ;
25892586 let mut found = false ;
25902587 for ty in field. walk ( ) {
25912588 if let ty:: TyParam ( p) = ty. sty {
@@ -2601,14 +2598,14 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
26012598 // TyError and ensure they do not affect any other fields.
26022599 // This could be checked after type collection for any struct
26032600 // with a potentially unsized trailing field.
2604- let types = substs_a. types . iter ( ) . enumerate ( ) . map ( |( i, ty) | {
2601+ let types = substs_a. types ( ) . enumerate ( ) . map ( |( i, ty) | {
26052602 if ty_params. contains ( i) {
26062603 tcx. types . err
26072604 } else {
26082605 ty
26092606 }
26102607 } ) . collect ( ) ;
2611- let substs = Substs :: new ( tcx, types, substs_a. regions . clone ( ) ) ;
2608+ let substs = Substs :: new ( tcx, types, substs_a. regions ( ) . cloned ( ) . collect ( ) ) ;
26122609 for & ty in fields. split_last ( ) . unwrap ( ) . 1 {
26132610 if ty. subst ( tcx, substs) . references_error ( ) {
26142611 return Err ( Unimplemented ) ;
@@ -2621,14 +2618,14 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
26212618
26222619 // Check that the source structure with the target's
26232620 // type parameters is a subtype of the target.
2624- let types = substs_a. types . iter ( ) . enumerate ( ) . map ( |( i, ty) | {
2621+ let types = substs_a. types ( ) . enumerate ( ) . map ( |( i, ty) | {
26252622 if ty_params. contains ( i) {
2626- substs_b. types [ i ]
2623+ substs_b. type_at ( i )
26272624 } else {
26282625 ty
26292626 }
26302627 } ) . collect ( ) ;
2631- let substs = Substs :: new ( tcx, types, substs_a. regions . clone ( ) ) ;
2628+ let substs = Substs :: new ( tcx, types, substs_a. regions ( ) . cloned ( ) . collect ( ) ) ;
26322629 let new_struct = tcx. mk_struct ( def, substs) ;
26332630 let origin = TypeOrigin :: Misc ( obligation. cause . span ) ;
26342631 let InferOk { obligations, .. } =
@@ -2753,7 +2750,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
27532750 // substitution if we find that any of the input types, when
27542751 // simplified, do not match.
27552752
2756- obligation. predicate . 0 . input_types ( ) . iter ( )
2753+ obligation. predicate . skip_binder ( ) . input_types ( )
27572754 . zip ( impl_trait_ref. input_types ( ) )
27582755 . any ( |( & obligation_ty, & impl_ty) | {
27592756 let simplified_obligation_ty =
0 commit comments