make Va::arg and VaList::drop const fns
This commit is contained in:
parent
a7888c1342
commit
ce693807f6
3 changed files with 18 additions and 4 deletions
|
|
@ -216,7 +216,8 @@ impl Clone for VaList<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'f> Drop for VaList<'f> {
|
||||
#[rustc_const_unstable(feature = "c_variadic_const", issue = "none")]
|
||||
impl<'f> const Drop for VaList<'f> {
|
||||
fn drop(&mut self) {
|
||||
// SAFETY: this variable argument list is being dropped, so won't be read from again.
|
||||
unsafe { va_end(self) }
|
||||
|
|
@ -291,7 +292,8 @@ impl<'f> VaList<'f> {
|
|||
///
|
||||
/// [valid]: https://doc.rust-lang.org/nightly/nomicon/what-unsafe-does.html
|
||||
#[inline]
|
||||
pub unsafe fn arg<T: VaArgSafe>(&mut self) -> T {
|
||||
#[rustc_const_unstable(feature = "c_variadic_const", issue = "none")]
|
||||
pub const unsafe fn arg<T: VaArgSafe>(&mut self) -> T {
|
||||
// SAFETY: the caller must uphold the safety contract for `va_arg`.
|
||||
unsafe { va_arg(self) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3472,7 +3472,7 @@ pub(crate) const fn miri_promise_symbolic_alignment(ptr: *const (), align: usize
|
|||
///
|
||||
#[rustc_intrinsic]
|
||||
#[rustc_nounwind]
|
||||
pub unsafe fn va_arg<T: VaArgSafe>(ap: &mut VaList<'_>) -> T;
|
||||
pub const unsafe fn va_arg<T: VaArgSafe>(ap: &mut VaList<'_>) -> T;
|
||||
|
||||
/// Duplicates a variable argument list. The returned list is initially at the same position as
|
||||
/// the one in `src`, but can be advanced independently.
|
||||
|
|
@ -3503,6 +3503,6 @@ pub fn va_copy<'f>(src: &VaList<'f>) -> VaList<'f> {
|
|||
///
|
||||
#[rustc_intrinsic]
|
||||
#[rustc_nounwind]
|
||||
pub unsafe fn va_end(ap: &mut VaList<'_>) {
|
||||
pub const unsafe fn va_end(ap: &mut VaList<'_>) {
|
||||
/* deliberately does nothing */
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue