diff --git a/clippy_lints/src/misc_early.rs b/clippy_lints/src/misc_early.rs index f4a1a1e297fc..47446edac54b 100644 --- a/clippy_lints/src/misc_early.rs +++ b/clippy_lints/src/misc_early.rs @@ -312,7 +312,7 @@ impl EarlyLintPass for MiscEarlyLints { if let PatKind::Ident(_, ident, Some(ref right)) = pat.node { if let PatKind::Wild = right.node { - span_lint( + span_lint_and_sugg( cx, REDUNDANT_PATTERN, pat.span, @@ -320,6 +320,9 @@ impl EarlyLintPass for MiscEarlyLints { "the `{} @ _` pattern can be written as just `{}`", ident.name, ident.name, ), + "try", + format!("{}", ident.name), + Applicability::MachineApplicable, ); } } diff --git a/tests/ui/patterns.stderr b/tests/ui/patterns.stderr index 31dfe1cd11c5..f25e71e872b2 100644 --- a/tests/ui/patterns.stderr +++ b/tests/ui/patterns.stderr @@ -2,7 +2,7 @@ error: the `y @ _` pattern can be written as just `y` --> $DIR/patterns.rs:10:9 | LL | y @ _ => (), - | ^^^^^ + | ^^^^^ help: try: `y` | = note: `-D clippy::redundant-pattern` implied by `-D warnings`