VARARGS_WITHOUT_PATTERN in rustc_lint_defs::builtin - Rust
Description: The `varargs_without_pattern` lint detects when `...` is used as an argument to a non-foreign function without any pattern being specified.

Skip to main content

## VARARGS_WITHOUT_PATTERN

# Static VARARGS_WITHOUT_PATTERN

Source

    pub static VARARGS_WITHOUT_PATTERN: &Lint

Expand 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(...) {

    }

{{produces}}

#### §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 definitions 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 definitions.

Using `...` (C varargs) in a non-foreign function definition is currently unstable. 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 situation where this lint affects code that compiles on stable Rust.

This is a future-incompatible lint to transition this to a hard error in the future.