1
- use clippy_utils:: diagnostics:: span_lint_and_help;
2
- use clippy_utils:: { is_wild, meets_msrv, msrvs} ;
3
- use rustc_hir:: { Arm , Expr , ExprKind , Local , MatchSource , Pat , PatKind } ;
1
+ use clippy_utils:: { meets_msrv, msrvs} ;
2
+ use rustc_hir:: { Expr , ExprKind , Local , MatchSource , Pat } ;
4
3
use rustc_lint:: { LateContext , LateLintPass } ;
5
4
use rustc_semver:: RustcVersion ;
6
5
use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
@@ -18,6 +17,7 @@ mod overlapping_arms;
18
17
mod redundant_pattern_match;
19
18
mod rest_pat_in_fully_bound_struct;
20
19
mod single_match;
20
+ mod wild_in_or_pats;
21
21
22
22
declare_clippy_lint ! {
23
23
/// ### What it does
@@ -621,7 +621,7 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
621
621
match_wild_err_arm:: check ( cx, ex, arms) ;
622
622
match_wild_enum:: check ( cx, ex, arms) ;
623
623
match_as_ref:: check ( cx, ex, arms, expr) ;
624
- check_wild_in_or_pats ( cx, arms) ;
624
+ wild_in_or_pats :: check ( cx, arms) ;
625
625
626
626
if self . infallible_destructuring_match_linted {
627
627
self . infallible_destructuring_match_linted = false ;
@@ -644,21 +644,3 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
644
644
645
645
extract_msrv_attr ! ( LateContext ) ;
646
646
}
647
-
648
- fn check_wild_in_or_pats ( cx : & LateContext < ' _ > , arms : & [ Arm < ' _ > ] ) {
649
- for arm in arms {
650
- if let PatKind :: Or ( fields) = arm. pat . kind {
651
- // look for multiple fields in this arm that contains at least one Wild pattern
652
- if fields. len ( ) > 1 && fields. iter ( ) . any ( is_wild) {
653
- span_lint_and_help (
654
- cx,
655
- WILDCARD_IN_OR_PATTERNS ,
656
- arm. pat . span ,
657
- "wildcard pattern covers any other pattern as it will match anyway" ,
658
- None ,
659
- "consider handling `_` separately" ,
660
- ) ;
661
- }
662
- }
663
- }
664
- }
0 commit comments