about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--clippy_lints/src/misc_early.rs5
-rw-r--r--tests/ui/patterns.stderr2
2 files changed, 5 insertions, 2 deletions
diff --git a/clippy_lints/src/misc_early.rs b/clippy_lints/src/misc_early.rs
index f4a1a1e297f..47446edac54 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 31dfe1cd11c..f25e71e872b 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`