@@ -213,14 +213,15 @@ crate::cfg_select! {
213213/// assert_eq!(unsafe { my_func(3, 42i32, -7i32, 20i32) }, 55);
214214/// ```
215215///
216- /// The [`VaList::arg`] method can be used to read an argument from the list. This method
217- /// automatically advances the `VaList` to the next argument. The C equivalent is `va_arg`.
216+ /// The [`VaList::arg`] method reads the next argument from the variable argument list,
217+ /// and is equivalent to C `va_arg`.
218218///
219219/// Cloning a `VaList` performs the equivalent of C `va_copy`, producing an independent cursor
220220/// that arguments can be read from without affecting the original. Dropping a `VaList` performs
221221/// the equivalent of C `va_end`.
222222///
223- /// This can be used across an FFI boundary, and fully matches the platform's `va_list`.
223+ /// A `VaList` can be used across an FFI boundary, and fully matches the platform's `va_list` in
224+ /// terms of layout and ABI.
224225#[ repr( transparent) ]
225226#[ lang = "va_list" ]
226227pub struct VaList < ' a > {
@@ -285,17 +286,33 @@ mod sealed {
285286
286287/// Types that are valid to read using [`VaList::arg`].
287288///
288- /// # Safety
289+ /// This trait is implemented for primitive types that have a variable argument application-binary
290+ /// interface (ABI) on the current platform. It is always implemented for:
291+ ///
292+ /// - [`c_int`], [`c_long`] and [`c_longlong`]
293+ /// - [`c_uint`], [`c_ulong`] and [`c_ulonglong`]
294+ /// - [`c_double`]
295+ /// - `*const T` and `*mut T`
289296///
290- /// The standard library implements this trait for primitive types that are
291- /// expected to have a variable argument application-binary interface (ABI) on all
292- /// platforms.
297+ /// Implementations for e.g. `i32` or `usize` shouldn't be relied upon directly,
298+ /// because they may not be available on all platforms.
299+ ///
300+ /// # Safety
293301///
294- /// When C passes variable arguments, integers smaller than [`c_int`] and floats smaller
295- /// than [`c_double`] are implicitly promoted to [`c_int`] and [`c_double`] respectively.
296- /// Implementing this trait for types that are subject to this promotion rule is invalid.
302+ /// When C passes variable arguments, signed integers smaller than [`c_int`] are promoted
303+ /// to [`c_int`], unsigned integers smaller than [`c_uint`] are promoted to [`c_uint`],
304+ /// and [`c_float`] is promoted to [`c_double`]. Implementing this trait for types that are
305+ /// subject to this promotion rule is invalid.
297306///
298307/// [`c_int`]: core::ffi::c_int
308+ /// [`c_long`]: core::ffi::c_long
309+ /// [`c_longlong`]: core::ffi::c_longlong
310+ ///
311+ /// [`c_uint`]: core::ffi::c_uint
312+ /// [`c_ulong`]: core::ffi::c_ulong
313+ /// [`c_ulonglong`]: core::ffi::c_ulonglong
314+ ///
315+ /// [`c_float`]: core::ffi::c_float
299316/// [`c_double`]: core::ffi::c_double
300317// We may unseal this trait in the future, but currently our `va_arg` implementations don't support
301318// types with an alignment larger than 8, or with a non-scalar layout. Inline assembly can be used
@@ -352,14 +369,16 @@ const _: () = {
352369 va_arg_safe_check :: < crate :: ffi:: c_int > ( ) ;
353370 va_arg_safe_check :: < crate :: ffi:: c_uint > ( ) ;
354371 va_arg_safe_check :: < crate :: ffi:: c_long > ( ) ;
372+
355373 va_arg_safe_check :: < crate :: ffi:: c_ulong > ( ) ;
356374 va_arg_safe_check :: < crate :: ffi:: c_longlong > ( ) ;
357375 va_arg_safe_check :: < crate :: ffi:: c_ulonglong > ( ) ;
376+
358377 va_arg_safe_check :: < crate :: ffi:: c_double > ( ) ;
359378} ;
360379
361380impl < ' f > VaList < ' f > {
362- /// Read an argument from the variable argument list, and advance to the next argument .
381+ /// Read the next argument from the variable argument list.
363382 ///
364383 /// Only types that implement [`VaArgSafe`] can be read from a variable argument list.
365384 ///
0 commit comments