@@ -644,8 +644,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
644
644
// This suffices to allow chains like `FnMut` implemented in
645
645
// terms of `Fn` etc, but we could probably make this more
646
646
// 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 ( ) ) ;
649
648
if unbound_input_types && self . intercrate {
650
649
debug ! ( "evaluate_stack({:?}) --> unbound argument, intercrate --> ambiguous" ,
651
650
stack. fresh_trait_ref) ;
@@ -1064,9 +1063,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
1064
1063
1065
1064
match * candidate {
1066
1065
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 ( )
1070
1067
}
1071
1068
}
1072
1069
@@ -1603,7 +1600,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
1603
1600
return ;
1604
1601
}
1605
1602
} ;
1606
- let target = obligation. predicate . skip_binder ( ) . input_types ( ) [ 1 ] ;
1603
+ let target = obligation. predicate . skip_binder ( ) . trait_ref . substs . type_at ( 1 ) ;
1607
1604
1608
1605
debug ! ( "assemble_candidates_for_unsizing(source={:?}, target={:?})" ,
1609
1606
source, target) ;
@@ -1936,7 +1933,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
1936
1933
1937
1934
// for `PhantomData<T>`, we pass `T`
1938
1935
ty:: TyStruct ( def, substs) if def. is_phantom_data ( ) => {
1939
- substs. types . to_vec ( )
1936
+ substs. types ( ) . cloned ( ) . collect ( )
1940
1937
}
1941
1938
1942
1939
ty:: TyStruct ( def, substs) | ty:: TyEnum ( def, substs) => {
@@ -2180,12 +2177,12 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
2180
2177
match self_ty. sty {
2181
2178
ty:: TyTrait ( ref data) => {
2182
2179
// 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 ( ) ;
2184
2181
let assoc_types = data. projection_bounds . iter ( )
2185
2182
. 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 ( ) ;
2189
2186
2190
2187
// reintroduce the two binding levels we skipped, then flatten into one
2191
2188
let all_types = ty:: Binder ( ty:: Binder ( all_types) ) ;
@@ -2476,7 +2473,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
2476
2473
// regions here. See the comment there for more details.
2477
2474
let source = self . infcx . shallow_resolve (
2478
2475
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 ) ;
2480
2477
let target = self . infcx . shallow_resolve ( target) ;
2481
2478
2482
2479
debug ! ( "confirm_builtin_unsize_candidate(source={:?}, target={:?})" ,
@@ -2585,7 +2582,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
2585
2582
} else {
2586
2583
return Err ( Unimplemented ) ;
2587
2584
} ;
2588
- let mut ty_params = BitVector :: new ( substs_a. types . len ( ) ) ;
2585
+ let mut ty_params = BitVector :: new ( substs_a. types ( ) . count ( ) ) ;
2589
2586
let mut found = false ;
2590
2587
for ty in field. walk ( ) {
2591
2588
if let ty:: TyParam ( p) = ty. sty {
@@ -2601,14 +2598,14 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
2601
2598
// TyError and ensure they do not affect any other fields.
2602
2599
// This could be checked after type collection for any struct
2603
2600
// 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) | {
2605
2602
if ty_params. contains ( i) {
2606
2603
tcx. types . err
2607
2604
} else {
2608
2605
ty
2609
2606
}
2610
2607
} ) . collect ( ) ;
2611
- let substs = Substs :: new ( tcx, types, substs_a. regions . clone ( ) ) ;
2608
+ let substs = Substs :: new ( tcx, types, substs_a. regions ( ) . cloned ( ) . collect ( ) ) ;
2612
2609
for & ty in fields. split_last ( ) . unwrap ( ) . 1 {
2613
2610
if ty. subst ( tcx, substs) . references_error ( ) {
2614
2611
return Err ( Unimplemented ) ;
@@ -2621,14 +2618,14 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
2621
2618
2622
2619
// Check that the source structure with the target's
2623
2620
// 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) | {
2625
2622
if ty_params. contains ( i) {
2626
- substs_b. types [ i ]
2623
+ substs_b. type_at ( i )
2627
2624
} else {
2628
2625
ty
2629
2626
}
2630
2627
} ) . collect ( ) ;
2631
- let substs = Substs :: new ( tcx, types, substs_a. regions . clone ( ) ) ;
2628
+ let substs = Substs :: new ( tcx, types, substs_a. regions ( ) . cloned ( ) . collect ( ) ) ;
2632
2629
let new_struct = tcx. mk_struct ( def, substs) ;
2633
2630
let origin = TypeOrigin :: Misc ( obligation. cause . span ) ;
2634
2631
let InferOk { obligations, .. } =
@@ -2753,7 +2750,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
2753
2750
// substitution if we find that any of the input types, when
2754
2751
// simplified, do not match.
2755
2752
2756
- obligation. predicate . 0 . input_types ( ) . iter ( )
2753
+ obligation. predicate . skip_binder ( ) . input_types ( )
2757
2754
. zip ( impl_trait_ref. input_types ( ) )
2758
2755
. any ( |( & obligation_ty, & impl_ty) | {
2759
2756
let simplified_obligation_ty =
0 commit comments