Skip to content

transpile: emit VaList::next_arg instead of arg for edition 2024 #2033

Description

@thedataking

rust-lang/rust#155614 renamed VaList::arg to VaList::next_arg, in nightlies from 2026-04-24 on. c2rust still emits .arg::<T>() for va_arg in every edition, so --edition 2024 output for a function that uses va_arg only builds on nightlies before that date.

c2rust-transpile/src/translator/variadic.rs (line 238 on master a9bcc81) emits mk().ident("arg") unconditionally, while mk_va_list_ty and mk_va_list_copy in the same file already switch on the edition. The Edition2024 toolchain is pinned to nightly-2026-03-03 in c2rust-rust-tools/src/lib.rs, which predates the rename, so nothing in the tree notices.

Repro

#include <stdarg.h>

int sum(int n, ...) {
    va_list ap;
    va_start(ap, n);
    int s = 0;
    while (n--) s += va_arg(ap, int);
    va_end(ap);
    return s;
}
c2rust transpile --edition 2024 compile_commands.json --emit-build-files -o out

This emits:

    let mut ap: ::core::ffi::VaList;
    ap = c2rust_args.clone();
    ...
        s += ap.arg::<::core::ffi::c_int>();

cargo check on the output passes with the pinned nightly-2026-03-03. With nightly-2026-05-11 and nightly-2026-08-02 it fails:

error[E0599]: no method named `arg` found for struct `VaList<'a>` in the current scope
  --> src/va.rs:25:17
   |
25 |         s += ap.arg::<::core::ffi::c_int>();
   |                 ^^^ method not found in `VaList<'_>`

Tested with c2rust built from f19c646. The code is unchanged on master.

Suggestion

For Edition2024, emit next_arg and move the pinned toolchain to nightly-2026-04-24 or later. c_variadic was stabilized in rust-lang/rust#155697 (merged 2026-07-22), so with a toolchain from after that, the #![feature(c_variadic)] attribute can go too.

Context: Tractor-Crisp builds c2rust's edition-2021 output on nightly-2026-08-02 and now rewrites .arg::< to .next_arg::< after transpiling (GaloisInc/Tractor-Crisp#211).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions