Skip to content

Tracking Issue for future-incompatibility lint varargs_without_pattern #145544

@beetrees

Description

@beetrees

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-future-incompatibilityCategory: Future-incompatibility lintsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCF-c_variadic`#![feature(c_variadic)]`T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions