@@ -3219,6 +3219,22 @@ impl<'c> Translation<'c> {
3219
3219
. collect ( )
3220
3220
}
3221
3221
3222
+ /// Variant of `convert_exprs` for when only a prefix of the expression types are known due to
3223
+ /// the relevant signature being varargs
3224
+ #[ allow( clippy:: vec_box/*, reason = "not worth a substantial refactor"*/ ) ]
3225
+ fn convert_exprs_partial (
3226
+ & self ,
3227
+ ctx : ExprContext ,
3228
+ exprs : & [ CExprId ] ,
3229
+ arg_tys : & [ CQualTypeId ] ,
3230
+ ) -> TranslationResult < WithStmts < Vec < Box < Expr > > > > {
3231
+ exprs
3232
+ . iter ( )
3233
+ . enumerate ( )
3234
+ . map ( |( n, arg) | self . convert_expr ( ctx, * arg, arg_tys. get ( n) . copied ( ) ) )
3235
+ . collect ( )
3236
+ }
3237
+
3222
3238
/// Translate a C expression into a Rust one, possibly collecting side-effecting statements
3223
3239
/// to run before the expression.
3224
3240
///
@@ -3853,13 +3869,19 @@ impl<'c> Translation<'c> {
3853
3869
// We want to decay refs only when function is variadic
3854
3870
ctx. decay_ref = DecayRef :: from ( is_variadic) ;
3855
3871
3856
- let arg_tys = if let ( false , Some ( arg_tys ) ) = ( is_variadic, & arg_tys ) {
3857
- assert ! ( arg_tys. len ( ) == args . len ( ) ) ;
3858
- Some ( arg_tys. as_slice ( ) )
3872
+ let args = if is_variadic {
3873
+ let arg_tys = arg_tys . unwrap_or_default ( ) ;
3874
+ self . convert_exprs_partial ( ctx . used ( ) , args , arg_tys. as_slice ( ) ) ?
3859
3875
} else {
3860
- None
3876
+ let arg_tys = if let Some ( ref arg_tys) = arg_tys {
3877
+ assert ! ( arg_tys. len( ) == args. len( ) ) ;
3878
+ Some ( arg_tys. as_slice ( ) )
3879
+ } else {
3880
+ None
3881
+ } ;
3882
+
3883
+ self . convert_exprs ( ctx. used ( ) , args, arg_tys) ?
3861
3884
} ;
3862
- let args = self . convert_exprs ( ctx. used ( ) , args, arg_tys) ?;
3863
3885
3864
3886
let mut call_expr = args. map ( |args| mk ( ) . call_expr ( func, args) ) ;
3865
3887
if let Some ( expected_ty) = override_ty {
0 commit comments