@@ -1651,6 +1651,11 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
16511651 def_id_a == def_id_b
16521652 }
16531653
1654+ // (.., T) -> (.., U).
1655+ ( & ty:: TyTuple ( tys_a, _) , & ty:: TyTuple ( tys_b, _) ) => {
1656+ tys_a. len ( ) == tys_b. len ( )
1657+ }
1658+
16541659 _ => false
16551660 } ;
16561661
@@ -2617,6 +2622,37 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
26172622 & [ inner_target] ) ) ;
26182623 }
26192624
2625+ // (.., T) -> (.., U).
2626+ ( & ty:: TyTuple ( tys_a, _) , & ty:: TyTuple ( tys_b, _) ) => {
2627+ assert_eq ! ( tys_a. len( ) , tys_b. len( ) ) ;
2628+
2629+ // The last field of the tuple has to exist.
2630+ let ( a_last, a_mid) = if let Some ( x) = tys_a. split_last ( ) {
2631+ x
2632+ } else {
2633+ return Err ( Unimplemented ) ;
2634+ } ;
2635+ let b_last = tys_b. last ( ) . unwrap ( ) ;
2636+
2637+ // Check that the source tuple with the target's
2638+ // last element is a subtype of the target.
2639+ let new_tuple = tcx. mk_tup ( a_mid. iter ( ) . chain ( Some ( b_last) ) , false ) ;
2640+ let InferOk { obligations, .. } =
2641+ self . infcx . at ( & obligation. cause , obligation. param_env )
2642+ . eq ( target, new_tuple)
2643+ . map_err ( |_| Unimplemented ) ?;
2644+ self . inferred_obligations . extend ( obligations) ;
2645+
2646+ // Construct the nested T: Unsize<U> predicate.
2647+ nested. push ( tcx. predicate_for_trait_def (
2648+ obligation. param_env ,
2649+ obligation. cause . clone ( ) ,
2650+ obligation. predicate . def_id ( ) ,
2651+ obligation. recursion_depth + 1 ,
2652+ a_last,
2653+ & [ b_last] ) ) ;
2654+ }
2655+
26202656 _ => bug ! ( )
26212657 } ;
26222658
0 commit comments