@@ -646,16 +646,9 @@ impl<'c> Translation<'c> {
646
646
) -> TranslationResult < WithStmts < Box < Expr > > > {
647
647
let args = self . convert_exprs ( ctx. used ( ) , args) ?;
648
648
args. and_then ( |args| {
649
- let mut args = args. into_iter ( ) ;
650
- let a = args
651
- . next ( )
652
- . ok_or ( "Missing first argument to convert_overflow_arith" ) ?;
653
- let b = args
654
- . next ( )
655
- . ok_or ( "Missing second argument to convert_overflow_arith" ) ?;
656
- let c = args
657
- . next ( )
658
- . ok_or ( "Missing third argument to convert_overflow_arith" ) ?;
649
+ let [ a, b, c] : [ _ ; 3 ] = args
650
+ . try_into ( )
651
+ . map_err ( |_| "`convert_overflow_arith` must have exactly 3 arguments" ) ?;
659
652
let overflowing = mk ( ) . method_call_expr ( a, method_name, vec ! [ b] ) ;
660
653
let sum_name = self . renamer . borrow_mut ( ) . fresh ( ) ;
661
654
let over_name = self . renamer . borrow_mut ( ) . fresh ( ) ;
@@ -691,16 +684,9 @@ impl<'c> Translation<'c> {
691
684
let mem = mk ( ) . path_expr ( vec ! [ "libc" , name] ) ;
692
685
let args = self . convert_exprs ( ctx. used ( ) , args) ?;
693
686
args. and_then ( |args| {
694
- let mut args = args. into_iter ( ) ;
695
- let dst = args
696
- . next ( )
697
- . ok_or ( "Missing dst argument to convert_libc_fns" ) ?;
698
- let c = args
699
- . next ( )
700
- . ok_or ( "Missing c argument to convert_libc_fns" ) ?;
701
- let len = args
702
- . next ( )
703
- . ok_or ( "Missing len argument to convert_libc_fns" ) ?;
687
+ let [ dst, c, len] : [ _ ; 3 ] = args
688
+ . try_into ( )
689
+ . map_err ( |_| "`convert_libc_fns` must have exactly 3 arguments: [dst, c, len]" ) ?;
704
690
let size_t = mk ( ) . path_ty ( vec ! [ "libc" , "size_t" ] ) ;
705
691
let len1 = mk ( ) . cast_expr ( len, size_t) ;
706
692
let mem_expr = mk ( ) . call_expr ( mem, vec ! [ dst, c, len1] ) ;
0 commit comments