|
1 | 1 | mod builtin_type_shadow; |
2 | 2 | mod double_neg; |
| 3 | +mod redundant_pattern; |
3 | 4 |
|
4 | 5 | use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then}; |
5 | 6 | use clippy_utils::source::snippet_opt; |
6 | | -use rustc_ast::ast::{ |
7 | | - BindingMode, Expr, Generics, Lit, LitFloatType, LitIntType, LitKind, Mutability, NodeId, Pat, PatKind, |
8 | | -}; |
| 7 | +use rustc_ast::ast::{Expr, Generics, Lit, LitFloatType, LitIntType, LitKind, NodeId, Pat, PatKind}; |
9 | 8 | use rustc_ast::visit::FnKind; |
10 | 9 | use rustc_data_structures::fx::FxHashMap; |
11 | 10 | use rustc_errors::Applicability; |
@@ -336,29 +335,7 @@ impl EarlyLintPass for MiscEarlyLints { |
336 | 335 | } |
337 | 336 | } |
338 | 337 |
|
339 | | - if let PatKind::Ident(left, ident, Some(ref right)) = pat.kind { |
340 | | - let left_binding = match left { |
341 | | - BindingMode::ByRef(Mutability::Mut) => "ref mut ", |
342 | | - BindingMode::ByRef(Mutability::Not) => "ref ", |
343 | | - BindingMode::ByValue(..) => "", |
344 | | - }; |
345 | | - |
346 | | - if let PatKind::Wild = right.kind { |
347 | | - span_lint_and_sugg( |
348 | | - cx, |
349 | | - REDUNDANT_PATTERN, |
350 | | - pat.span, |
351 | | - &format!( |
352 | | - "the `{} @ _` pattern can be written as just `{}`", |
353 | | - ident.name, ident.name, |
354 | | - ), |
355 | | - "try", |
356 | | - format!("{}{}", left_binding, ident.name), |
357 | | - Applicability::MachineApplicable, |
358 | | - ); |
359 | | - } |
360 | | - } |
361 | | - |
| 338 | + redundant_pattern::check(cx, pat); |
362 | 339 | check_unneeded_wildcard_pattern(cx, pat); |
363 | 340 | } |
364 | 341 |
|
|
0 commit comments