Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

beetrees
Copy link
Contributor

@beetrees beetrees commented Jul 7, 2025

This PR makes ... arguments without a pattern in non-foreign functions (such as the argument in unsafe extern "C" fn f(...) {}) a future-compatibility warning; making this error would be consistent with how unsafe extern "C" fn f(u32) {} is handled. Allowing ... arguments without a pattern in non-foreign functions is a source of confusion for programmers coming from C, where the ... parameter is never named and instead calling va_start is required; disallowing ... arguments without a pattern also improves the overall consistency of the Rust language by matching the treatment of other arguments without patterns. ... arguments without a pattern in extern blocks (such as unsafe extern "C" { fn f(...); }) continue to compile without warnings 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 a Crater run shows only the binrw crate is using this, I think it would be ok to break this. This will require a lang FCP.

The idea of rejecting ... pre-expansion was first raised here #143546 (comment).

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".

@beetrees
Copy link
Contributor Author

beetrees commented Jul 8, 2025

Unknown command "tryfor".

@compiler-errors

@compiler-errors
Copy link
Member

wild

@bors2 try

rust-bors bot added a commit that referenced this pull request Jul 8, 2025
`c_variadic`: Make `fn f(...) {}` error like `fn f(u32) {}` outside of `extern` blocks

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:
```rust
#[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`
@rust-bors
Copy link

rust-bors bot commented Jul 8, 2025

⌛ Trying commit e18dc17 with merge e784c10

To cancel the try build, run the command @bors2 try cancel.

@rust-bors
Copy link

rust-bors bot commented Jul 8, 2025

☀️ Try build successful (CI)
Build commit: e784c10 (e784c10fc2dd34bf2bb7b1e51117e35d3f9c5837, parent: 040e2f8b9ff2d76fbe2146d6003e297ed4532088)

@folkertdev
Copy link
Contributor

So, should we start that crater run here?

@beetrees
Copy link
Contributor Author

@compiler-errors could you @craterbot check?

@compiler-errors
Copy link
Member

👍

@craterbot check

@craterbot
Copy link
Collaborator

👌 Experiment pr-143619 created and queued.
🤖 Automatically detected try build e784c10
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 14, 2025
@craterbot
Copy link
Collaborator

🚧 Experiment pr-143619 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🚨 Report generation of pr-143619 failed: timed out waiting for connection
🛠️ If the error is fixed use the retry-report command.

🆘 If you need assistance dealing with this failure, please ask in t-infra on Zulip
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@folkertdev
Copy link
Contributor

not sure I have the permissions for this, but let's attempt

@craterbot retry-report

@craterbot
Copy link
Collaborator

🛠️ Generation of the report for pr-143619 queued again.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🚨 Report generation of pr-143619 failed: timed out waiting for connection
🛠️ If the error is fixed use the retry-report command.

🆘 If you need assistance dealing with this failure, please ask in t-infra on Zulip
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@folkertdev
Copy link
Contributor

let's try again with rust-lang/crater#787 merged

@craterbot retry-report

@craterbot
Copy link
Collaborator

🛠️ Generation of the report for pr-143619 queued again.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🎉 Experiment pr-143619 is completed!
📊 183 regressed and 4 fixed (664923 total)
📰 Open the summary report.

⚠️ If you notice any spurious failure please add them to the denylist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot removed the S-waiting-on-crater Status: Waiting on a crater run to be completed. label Jul 19, 2025
@folkertdev
Copy link
Contributor

Now that FCP is complete this needs review from T-compiler

r? T-compiler

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 2, 2025
@rustbot rustbot assigned estebank and unassigned joshtriplett Sep 2, 2025
@bors
Copy link
Collaborator

bors commented Sep 2, 2025

☔ The latest upstream changes (presumably #146125) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Sep 4, 2025

☔ The latest upstream changes (presumably #146185) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Sep 8, 2025

☔ The latest upstream changes (presumably #146165) made this pull request unmergeable. Please resolve the merge conflicts.

@folkertdev folkertdev added the F-c_variadic `#![feature(c_variadic)]` label Sep 9, 2025
@rustbot

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Sep 11, 2025

☔ The latest upstream changes (presumably #146418) made this pull request unmergeable. Please resolve the merge conflicts.

…without a pattern outside of `extern` blocks
@rustbot
Copy link
Collaborator

rustbot commented Sep 11, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@bors
Copy link
Collaborator

bors commented Sep 18, 2025

☔ The latest upstream changes (presumably #146727) made this pull request unmergeable. Please resolve the merge conflicts.

/// // currently only checked after attributes are expanded, so using `#[cfg(false)]` here will
/// // allow this to compile on stable Rust.
/// #[cfg(false)]
/// fn foo(...) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you give an example of a correct usage, with a pattern?

///
/// Patterns are currently required for all non-`...` arguments in function definitions (with
/// some exceptions in the 2015 edition). Requiring `...` arguments to have patterns in
/// non-foreign function definitions makes the language more consistent, and removes a source of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like, with a block here that's "A correct usage of ... in the above example would be fn foo(_: ...) {}"

@jdonszelmann
Copy link
Contributor

other than that, the changes look good (from a T-compiler POV)

@jdonszelmann
Copy link
Contributor

could you rebase on master?

@jdonszelmann
Copy link
Contributor

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 19, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 19, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. F-c_variadic `#![feature(c_variadic)]` finished-final-comment-period The final comment period is finished for this PR / Issue. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team
Projects
None yet
Development

Successfully merging this pull request may close these issues.