From 8be37fdb1d50498bdc3a860dd07d79c847247d0c Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 5 Sep 2019 00:50:22 +0900 Subject: [PATCH] Make it auto fixable lint --- clippy_lints/src/misc_early.rs | 5 ++++- tests/ui/patterns.stderr | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) 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`