rust-lang / rust-lang/rust

Tracking Issue for future-incompatibility lint `varargs_without_pattern`

Open
#145,544 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-future-incompatibility C-tracking-issue F-c_variadic T-lang
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

The varargs_without_pattern lint detects when ... is used as an argument to a non-foreign function without any pattern being specified.

Example
// Using `...` in non-foreign function definitions is unstable, however stability is
// currently only checked after attributes are expanded, so using `#[cfg(false)]` here will
// allow this to compile on stable Rust.
#[cfg(false)]
fn foo(...) {

}

This will produce:

warning: missing pattern for `...` argument
 --> lint_example.rs:6:8
  |
6 | fn foo(...) {
  |        ^^^
  |
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: for more information, see issue #145544 <https://github.com/rust-lang/rust/issues/145544>
  = note: `#[warn(varargs_without_pattern)]` on by default
help: name the argument, or use `_` to continue ignoring it
  |
6 | fn foo(_: ...) {
  |        ++
Explanation

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 defitions makes the language more consistent, and removes a source of confusion for the unstable C variadic feature. ... arguments without a pattern are already stable and widely used in foreign function definitions; this lint only affects non-foreign function defitions.

Using ... (C varargs) in a non-foreign function definition is currently unstable (#44930). However, stability checking for the ... syntax in non-foreign function definitions is currently implemented after attributes have been expanded, meaning that if the attribute removes the use of the unstable syntax (e.g. #[cfg(false)], or a procedural macro), the code will compile on stable Rust; this is the only situtation where this lint affects code that compiles on stable Rust.

Implementation history
  • #143619

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source files or tests are named in the issue. Start by reading the lint description and implementation history in #143619, then inspect the compiler's handling of varargs and future-incompatibility lints. The issue does not define a concrete follow-up or completion test, so the scope needs clarification before work begins.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.