ANONYMOUS_PARAMETERS in rustc_lint::builtin - Rust
Description: The `anonymous_parameters` lint detects anonymous parameters in trait definitions.

Skip to main content

## ANONYMOUS_PARAMETERS

# Static ANONYMOUS_PARAMETERS

Source

    pub static ANONYMOUS_PARAMETERS: &Lint

Expand description

The `anonymous_parameters` lint detects anonymous parameters in trait definitions.

#### §Example

ⓘ

    #![deny(anonymous_parameters)]
    // edition 2015
    pub trait Foo {
        fn foo(usize);
    }
    fn main() {}

{{produces}}

#### §Explanation

This syntax is mostly a historical accident, and can be worked around quite easily by adding an `_` pattern or a descriptive identifier:

    trait Foo {
        fn foo(_: usize);
    }

This syntax is now a hard error in the 2018 edition. In the 2015 edition, this lint is “warn” by default. This lint enables the `cargo fix` tool with the `--edition` flag to automatically transition old code from the 2015 edition to 2018. The tool will run this lint and automatically apply the suggested fix from the compiler (which is to add `_` to each parameter). This provides a completely automated way to update old code for a new edition. See issue #41686 for more details.