@@ -1020,7 +1020,22 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
10201020 & ' a [ OpTy < ' tcx > ; N ] : TryFrom < & ' a [ OpTy < ' tcx > ] > ,
10211021 {
10221022 self . check_abi_and_shim_symbol_clash ( abi, exp_abi, link_name) ?;
1023- check_vargarg_fixed_arg_count ( link_name, abi, args)
1023+ if !abi. c_variadic {
1024+ throw_ub_format ! (
1025+ "calling a variadic function with a non-variadic caller-side signature"
1026+ ) ;
1027+ }
1028+ if abi. fixed_count != u32:: try_from ( N ) . unwrap ( ) {
1029+ throw_ub_format ! (
1030+ "incorrect number of fixed arguments for variadic function `{}`: got {}, expected {N}" ,
1031+ link_name. as_str( ) ,
1032+ abi. fixed_count
1033+ )
1034+ }
1035+ if let Some ( args) = args. split_first_chunk ( ) {
1036+ return interp_ok ( args) ;
1037+ }
1038+ panic ! ( "mismatch between signature and `args` slice" ) ;
10241039 }
10251040
10261041 /// Mark a machine allocation that was just created as immutable.
@@ -1233,34 +1248,6 @@ pub fn check_min_vararg_count<'a, 'tcx, const N: usize>(
12331248 )
12341249}
12351250
1236- /// Check the number of fixed args of a vararg function.
1237- /// Returns a tuple that consisting of an array of fixed args, and a slice of varargs.
1238- fn check_vargarg_fixed_arg_count < ' a , ' tcx , const N : usize > (
1239- link_name : Symbol ,
1240- abi : & FnAbi < ' tcx , Ty < ' tcx > > ,
1241- args : & ' a [ OpTy < ' tcx > ] ,
1242- ) -> InterpResult < ' tcx , ( & ' a [ OpTy < ' tcx > ; N ] , & ' a [ OpTy < ' tcx > ] ) > {
1243- if !abi. c_variadic {
1244- throw_ub_format ! ( "calling a variadic function with a non-variadic caller-side signature" ) ;
1245- }
1246- if abi. fixed_count != u32:: try_from ( N ) . unwrap ( ) {
1247- throw_ub_format ! (
1248- "incorrect number of fixed arguments for variadic function `{}`: got {}, expected {N}" ,
1249- link_name. as_str( ) ,
1250- abi. fixed_count
1251- )
1252- }
1253- if let Some ( args) = args. split_first_chunk ( ) {
1254- return interp_ok ( args) ;
1255- }
1256- throw_ub_format ! (
1257- "incorrect number of arguments for `{}`: got {}, expected at least {}" ,
1258- link_name. as_str( ) ,
1259- args. len( ) ,
1260- N
1261- )
1262- }
1263-
12641251pub fn isolation_abort_error < ' tcx > ( name : & str ) -> InterpResult < ' tcx > {
12651252 throw_machine_stop ! ( TerminationInfo :: UnsupportedInIsolation ( format!(
12661253 "{name} not available when isolation is enabled" ,
0 commit comments