Description
There is no good way to perform syntax-directed translation of all possible C functions using va_list
into a corresponding Rust function using std::ffi::VaList::copy
. VaList
s copy
has the following signature:
pub unsafe fn copy<F, R>(&self, f: F) -> R
where F: for<'copy> FnOnce(VaList<'copy>) -> R;
copy
takes a closure whose input VaList
cannot outlive the closure (e.g. it cannot be passed back as a result of the closure). This is so that va_end
can be called on the input VaList
once the closure returns.
Since copy takes an immutable reference to the original va_list
and std::ffi::VaList::arg
requires a mutable reference, it is not possible to call std::ffi::VaList::arg
inside the closure passed to copy
. Therefore, a C function that calls va_arg
on two va_lists
(with one being a va_copy
of the other) in the same basic block, cannot be expressed using the current Rust variadic function API