@@ -537,8 +537,20 @@ impl<'a> InferenceContext<'a> {
537
537
let data = self . db . function_data ( func) ;
538
538
let ctx = crate :: lower:: TyLoweringContext :: new ( self . db , & self . resolver )
539
539
. with_impl_trait_mode ( ImplTraitLoweringMode :: Param ) ;
540
- let param_tys =
540
+ let mut param_tys =
541
541
data. params . iter ( ) . map ( |( _, type_ref) | ctx. lower_ty ( type_ref) ) . collect :: < Vec < _ > > ( ) ;
542
+ // Check if function contains a va_list, if it does then we append it to the parameter types
543
+ // that are collected from the function data
544
+ if data. is_varargs ( ) {
545
+ let va_list_ty = match self . resolve_va_list ( ) {
546
+ Some ( va_list) => TyBuilder :: adt ( self . db , va_list)
547
+ . fill_with_defaults ( self . db , || self . table . new_type_var ( ) )
548
+ . build ( ) ,
549
+ None => self . err_ty ( ) ,
550
+ } ;
551
+
552
+ param_tys. push ( va_list_ty)
553
+ }
542
554
for ( ty, pat) in param_tys. into_iter ( ) . zip ( self . body . params . iter ( ) ) {
543
555
let ty = self . insert_type_vars ( ty) ;
544
556
let ty = self . normalize_associated_types_in ( ty) ;
@@ -983,6 +995,11 @@ impl<'a> InferenceContext<'a> {
983
995
let trait_ = self . resolve_ops_index ( ) ?;
984
996
self . db . trait_data ( trait_) . associated_type_by_name ( & name ! [ Output ] )
985
997
}
998
+
999
+ fn resolve_va_list ( & self ) -> Option < AdtId > {
1000
+ let struct_ = self . resolve_lang_item ( name ! [ va_list] ) ?. as_struct ( ) ?;
1001
+ Some ( struct_. into ( ) )
1002
+ }
986
1003
}
987
1004
988
1005
/// When inferring an expression, we propagate downward whatever type hint we
0 commit comments