c-variadic functions in rustc_const_eval

This commit is contained in:
Folkert de Vries 2026-01-02 16:10:28 +01:00
parent ce693807f6
commit 02c4af397e
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
16 changed files with 908 additions and 33 deletions

View file

@ -200,12 +200,13 @@ impl fmt::Debug for VaList<'_> {
impl VaList<'_> {
// Helper used in the implementation of the `va_copy` intrinsic.
pub(crate) fn duplicate(&self) -> Self {
Self { inner: self.inner.clone(), _marker: self._marker }
pub(crate) const fn duplicate(&self) -> Self {
Self { inner: self.inner, _marker: self._marker }
}
}
impl Clone for VaList<'_> {
#[rustc_const_unstable(feature = "c_variadic_const", issue = "none")]
impl<'f> const Clone for VaList<'f> {
#[inline]
fn clone(&self) -> Self {
// We only implement Clone and not Copy because some future target might not be able to

View file

@ -3484,7 +3484,7 @@ pub const unsafe fn va_arg<T: VaArgSafe>(ap: &mut VaList<'_>) -> T;
/// when a variable argument list is used incorrectly.
#[rustc_intrinsic]
#[rustc_nounwind]
pub fn va_copy<'f>(src: &VaList<'f>) -> VaList<'f> {
pub const fn va_copy<'f>(src: &VaList<'f>) -> VaList<'f> {
src.duplicate()
}