@@ -3219,6 +3219,22 @@ impl<'c> Translation<'c> {
32193219 . collect ( )
32203220 }
32213221
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+
32223238 /// Translate a C expression into a Rust one, possibly collecting side-effecting statements
32233239 /// to run before the expression.
32243240 ///
@@ -3853,13 +3869,19 @@ impl<'c> Translation<'c> {
38533869 // We want to decay refs only when function is variadic
38543870 ctx. decay_ref = DecayRef :: from ( is_variadic) ;
38553871
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 ( ) ) ?
38593875 } 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) ?
38613884 } ;
3862- let args = self . convert_exprs ( ctx. used ( ) , args, arg_tys) ?;
38633885
38643886 let mut call_expr = args. map ( |args| mk ( ) . call_expr ( func, args) ) ;
38653887 if let Some ( expected_ty) = override_ty {
0 commit comments