[−][src]Static rustc_lint::builtin::ANONYMOUS_PARAMETERS

pub static ANONYMOUS_PARAMETERS: &Lint

The anonymous_parameters lint detects anonymous parameters in trait definitions.

Example

ⓘThis example deliberately fails to compile
#![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 "allow" by default, because the old code is still valid, and warning for all old code can be noisy. 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 switch this lint to "warn" and will 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.