Skip to content

c_variadic: Make fn f(...) {} error like fn f(u32) {} outside of extern blocks #143619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

beetrees
Copy link
Contributor

@beetrees beetrees commented Jul 7, 2025

This PR makes unnamed ... parameters (such as the one in unsafe extern "C" fn f(...) {}) a parse error to be consistent with unsafe extern "C" fn f(u32) {}: this is a source of confusion for programmers coming from C, where the ... parameter is never named and instead calling va_start is required; disallowing unnamed ... parameters also improves the overall consistency of the Rust language by matching the treatment of other unnamed parameters. Unnamed ... parameters in extern blocks (such as unsafe extern "C" { fn f(...); }) continue to compile after this PR, as they are already stable and heavily used (and don't cause the mentioned confusion as they are just being used in function declarations).

As all the syntax gating for c_variadic has been done post-expansion, this is technically a breaking change. In particular, code like this has compiled on stable since Rust 1.35.0:

#[cfg(any())] // Equivalent to the more recent #[cfg(false)]
unsafe extern "C" fn bar(_: u32, ...) {}

Since this is more or less a stability hole and is unlikely to be used in practice, I think it would be ok to break this, but this will definitely require both a crater check run and a lang FCP.

Tracking issue: #44930
cc @folkertdev @workingjubilee
r? @joshtriplett

@rustbot
Copy link
Collaborator

rustbot commented Jul 7, 2025

joshtriplett is not on the review rotation at the moment.
They may take a while to respond.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 7, 2025
@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Jul 8, 2025

This PR changes a file inside tests/crashes. If a crash was fixed, please move into the corresponding ui subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge.

@compiler-errors
Copy link
Member

@bors2 try

for the crater

@rust-bors
Copy link

rust-bors bot commented Jul 8, 2025

Unknown command "tryfor".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants