@@ -773,7 +773,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
773773
774774 // First, check if we just need to wrap some arguments in a tuple.
775775 if let Some ( ( mismatch_idx, terr) ) =
776- compatibility_diagonal. iter ( ) . enumerate ( ) . find_map ( |( i, c) | {
776+ compatibility_diagonal. iter_enumerated ( ) . find_map ( |( i, c) | {
777777 if let Compatibility :: Incompatible ( Some ( terr) ) = c {
778778 Some ( ( i, * terr) )
779779 } else {
@@ -785,23 +785,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
785785 // Do we have as many extra provided arguments as the tuple's length?
786786 // If so, we might have just forgotten to wrap some args in a tuple.
787787 if let Some ( ty:: Tuple ( tys) ) =
788- formal_and_expected_inputs. get ( mismatch_idx. into ( ) ) . map ( |tys| tys. 1 . kind ( ) )
788+ formal_and_expected_inputs. get ( mismatch_idx. to_expected_idx ( ) ) . map ( |tys| tys. 1 . kind ( ) )
789789 // If the tuple is unit, we're not actually wrapping any arguments.
790790 && !tys. is_empty ( )
791791 && provided_arg_tys. len ( ) == formal_and_expected_inputs. len ( ) - 1 + tys. len ( )
792792 {
793793 // Wrap up the N provided arguments starting at this position in a tuple.
794794 let provided_as_tuple = Ty :: new_tup_from_iter (
795795 tcx,
796- provided_arg_tys. iter ( ) . map ( |( ty, _) | * ty) . skip ( mismatch_idx) . take ( tys. len ( ) ) ,
796+ provided_arg_tys[ mismatch_idx..mismatch_idx. plus ( tys. len ( ) ) ]
797+ . iter ( )
798+ . map ( |& ( ty, _) | ty) ,
797799 ) ;
798800
799801 let mut satisfied = true ;
800802 // Check if the newly wrapped tuple + rest of the arguments are compatible.
801803 for ( ( _, expected_ty) , provided_ty) in std:: iter:: zip (
802- formal_and_expected_inputs. iter ( ) . skip ( mismatch_idx ) ,
804+ formal_and_expected_inputs[ mismatch_idx . to_expected_idx ( ) .. ] . iter ( ) ,
803805 [ provided_as_tuple] . into_iter ( ) . chain (
804- provided_arg_tys. iter ( ) . map ( |( ty, _) | * ty ) . skip ( mismatch_idx + tys . len ( ) ) ,
806+ provided_arg_tys[ mismatch_idx . plus ( tys . len ( ) ) .. ] . iter ( ) . map ( |& ( ty, _) | ty ) ,
805807 ) ,
806808 ) {
807809 if !self . may_coerce ( provided_ty, * expected_ty) {
@@ -814,10 +816,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
814816 // Take some care with spans, so we don't suggest wrapping a macro's
815817 // innards in parenthesis, for example.
816818 if satisfied
817- && let Some ( ( _, lo) ) =
818- provided_arg_tys. get ( ProvidedIdx :: from_usize ( mismatch_idx) )
819- && let Some ( ( _, hi) ) =
820- provided_arg_tys. get ( ProvidedIdx :: from_usize ( mismatch_idx + tys. len ( ) - 1 ) )
819+ && let Some ( ( _, lo) ) = provided_arg_tys. get ( mismatch_idx)
820+ // Note: `tys` is not an empty slice at this point
821+ && let Some ( ( _, hi) ) = provided_arg_tys. get ( mismatch_idx. plus ( tys. len ( ) - 1 ) )
821822 {
822823 let mut err;
823824 if tys. len ( ) == 1 {
@@ -826,8 +827,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
826827 err = self . err_ctxt ( ) . report_and_explain_type_error (
827828 mk_trace (
828829 * lo,
829- formal_and_expected_inputs[ mismatch_idx. into ( ) ] ,
830- provided_arg_tys[ mismatch_idx. into ( ) ] . 0 ,
830+ formal_and_expected_inputs[ mismatch_idx. to_expected_idx ( ) ] ,
831+ provided_arg_tys[ mismatch_idx] . 0 ,
831832 ) ,
832833 self . param_env ,
833834 terr,
@@ -866,7 +867,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
866867 callee_ty,
867868 call_expr,
868869 None ,
869- Some ( mismatch_idx) ,
870+ Some ( mismatch_idx. as_usize ( ) ) ,
870871 & matched_inputs,
871872 & formal_and_expected_inputs,
872873 is_method,
@@ -2648,7 +2649,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26482649 }
26492650
26502651 let expected_display_type = self
2651- . resolve_vars_if_possible ( formal_and_expected_inputs[ idx. into ( ) ] . 1 )
2652+ . resolve_vars_if_possible ( formal_and_expected_inputs[ idx] . 1 )
26522653 . sort_string ( self . tcx ) ;
26532654 let label = if idxs_matched == params_with_generics. len ( ) - 1 {
26542655 format ! (
0 commit comments