Skip to content

Commit 8be37fd

Browse files
committed
Make it auto fixable lint
1 parent e236740 commit 8be37fd

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

clippy_lints/src/misc_early.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,17 @@ impl EarlyLintPass for MiscEarlyLints {
312312

313313
if let PatKind::Ident(_, ident, Some(ref right)) = pat.node {
314314
if let PatKind::Wild = right.node {
315-
span_lint(
315+
span_lint_and_sugg(
316316
cx,
317317
REDUNDANT_PATTERN,
318318
pat.span,
319319
&format!(
320320
"the `{} @ _` pattern can be written as just `{}`",
321321
ident.name, ident.name,
322322
),
323+
"try",
324+
format!("{}", ident.name),
325+
Applicability::MachineApplicable,
323326
);
324327
}
325328
}

tests/ui/patterns.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: the `y @ _` pattern can be written as just `y`
22
--> $DIR/patterns.rs:10:9
33
|
44
LL | y @ _ => (),
5-
| ^^^^^
5+
| ^^^^^ help: try: `y`
66
|
77
= note: `-D clippy::redundant-pattern` implied by `-D warnings`
88

0 commit comments

Comments
 (0)