Skip to content

Commit

Permalink
Make it auto fixable lint
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Sep 4, 2019
1 parent e236740 commit 8be37fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion clippy_lints/src/misc_early.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,17 @@ 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,
&format!(
"the `{} @ _` pattern can be written as just `{}`",
ident.name, ident.name,
),
"try",
format!("{}", ident.name),
Applicability::MachineApplicable,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/patterns.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down

0 comments on commit 8be37fd

Please sign in to comment.