1
1
use clippy_utils:: diagnostics:: span_lint_and_help;
2
2
use clippy_utils:: { is_wild, meets_msrv, msrvs} ;
3
- use if_chain:: if_chain;
4
- use rustc_hir:: { Arm , Expr , ExprKind , Local , MatchSource , Pat , PatKind , QPath } ;
3
+ use rustc_hir:: { Arm , Expr , ExprKind , Local , MatchSource , Pat , PatKind } ;
5
4
use rustc_lint:: { LateContext , LateLintPass } ;
6
- use rustc_middle:: ty;
7
5
use rustc_semver:: RustcVersion ;
8
6
use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
9
7
@@ -18,6 +16,7 @@ mod match_wild_enum;
18
16
mod match_wild_err_arm;
19
17
mod overlapping_arms;
20
18
mod redundant_pattern_match;
19
+ mod rest_pat_in_fully_bound_struct;
21
20
mod single_match;
22
21
23
22
declare_clippy_lint ! {
@@ -640,26 +639,7 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
640
639
}
641
640
642
641
fn check_pat ( & mut self , cx : & LateContext < ' tcx > , pat : & ' tcx Pat < ' _ > ) {
643
- if_chain ! {
644
- if !pat. span. from_expansion( ) ;
645
- if let PatKind :: Struct ( QPath :: Resolved ( _, path) , fields, true ) = pat. kind;
646
- if let Some ( def_id) = path. res. opt_def_id( ) ;
647
- let ty = cx. tcx. type_of( def_id) ;
648
- if let ty:: Adt ( def, _) = ty. kind( ) ;
649
- if def. is_struct( ) || def. is_union( ) ;
650
- if fields. len( ) == def. non_enum_variant( ) . fields. len( ) ;
651
-
652
- then {
653
- span_lint_and_help(
654
- cx,
655
- REST_PAT_IN_FULLY_BOUND_STRUCTS ,
656
- pat. span,
657
- "unnecessary use of `..` pattern in struct binding. All fields were already bound" ,
658
- None ,
659
- "consider removing `..` from this binding" ,
660
- ) ;
661
- }
662
- }
642
+ rest_pat_in_fully_bound_struct:: check ( cx, pat) ;
663
643
}
664
644
665
645
extract_msrv_attr ! ( LateContext ) ;
0 commit comments