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 } ;
43use rustc_lint:: { LateContext , LateLintPass } ;
54use rustc_semver:: RustcVersion ;
65use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
@@ -18,6 +17,7 @@ mod overlapping_arms;
1817mod redundant_pattern_match;
1918mod rest_pat_in_fully_bound_struct;
2019mod single_match;
20+ mod wild_in_or_pats;
2121
2222declare_clippy_lint ! {
2323 /// ### What it does
@@ -621,7 +621,7 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
621621 match_wild_err_arm:: check ( cx, ex, arms) ;
622622 match_wild_enum:: check ( cx, ex, arms) ;
623623 match_as_ref:: check ( cx, ex, arms, expr) ;
624- check_wild_in_or_pats ( cx, arms) ;
624+ wild_in_or_pats :: check ( cx, arms) ;
625625
626626 if self . infallible_destructuring_match_linted {
627627 self . infallible_destructuring_match_linted = false ;
@@ -644,21 +644,3 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
644644
645645 extract_msrv_attr ! ( LateContext ) ;
646646}
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