From f53586e948f038abd691755194173d0e59f9ca19 Mon Sep 17 00:00:00 2001 From: LemonJ <1632798336@qq.com> Date: Thu, 13 Feb 2025 17:47:28 +0800 Subject: [PATCH] add safety contracts in VaListImpl arg --- library/core/src/ffi/va_list.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/library/core/src/ffi/va_list.rs b/library/core/src/ffi/va_list.rs index cceb186b31e79..0c26cf217561a 100644 --- a/library/core/src/ffi/va_list.rs +++ b/library/core/src/ffi/va_list.rs @@ -253,7 +253,12 @@ unsafe impl sealed_trait::VaArgSafe for *mut T {} unsafe impl sealed_trait::VaArgSafe for *const T {} impl<'f> VaListImpl<'f> { - /// Advance to the next arg. + /// Loads an argument of type `T` from the `va_list` and advance to the next arg. + /// + /// # Safety + /// + /// - Arg must be within the length of arg list when calling this method. + /// - The memory pointed to by the `va_list` must contain arguments of the correct types and sizes. #[inline] pub unsafe fn arg(&mut self) -> T { // SAFETY: the caller must uphold the safety contract for `va_arg`.