@@ -3,6 +3,7 @@ use clippy_utils::ty::is_type_diagnostic_item;
33use clippy_utils:: { is_refutable, peel_hir_pat_refs, recurse_or_patterns} ;
44use rustc_errors:: Applicability ;
55use rustc_hir:: def:: { CtorKind , DefKind , Res } ;
6+ use rustc_hir:: def_id:: DefId ;
67use rustc_hir:: { Arm , Expr , PatKind , PathSegment , QPath , Ty , TyKind } ;
78use rustc_lint:: LateContext ;
89use rustc_middle:: ty:: { self , VariantDef } ;
@@ -45,11 +46,11 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) {
4546
4647 // Accumulate the variants which should be put in place of the wildcard because they're not
4748 // already covered.
48- let has_hidden_external = adt_def. variants ( ) . iter ( ) . any ( |x| is_hidden_and_external ( cx, x) ) ;
49+ let has_hidden_external = adt_def. variants ( ) . iter ( ) . any ( |x| is_external_and_hidden ( cx, x) ) ;
4950 let mut missing_variants: Vec < _ > = adt_def
5051 . variants ( )
5152 . iter ( )
52- . filter ( |x| !is_hidden_and_external ( cx, x) )
53+ . filter ( |x| !is_external_and_hidden ( cx, x) )
5354 . collect ( ) ;
5455
5556 let mut path_prefix = CommonPrefixSearcher :: None ;
@@ -195,7 +196,14 @@ impl<'a> CommonPrefixSearcher<'a> {
195196 }
196197}
197198
198- fn is_hidden_and_external ( cx : & LateContext < ' _ > , variant_def : & VariantDef ) -> bool {
199- ( cx. tcx . is_doc_hidden ( variant_def. def_id ) || cx. tcx . has_attr ( variant_def. def_id , sym:: unstable) )
200- && variant_def. def_id . as_local ( ) . is_none ( )
199+ fn is_external_and_hidden ( cx : & LateContext < ' _ > , variant_def : & VariantDef ) -> bool {
200+ is_external ( variant_def. def_id ) && is_hidden ( cx, variant_def)
201+ }
202+
203+ fn is_hidden ( cx : & LateContext < ' _ > , variant_def : & VariantDef ) -> bool {
204+ cx. tcx . is_doc_hidden ( variant_def. def_id ) || cx. tcx . has_attr ( variant_def. def_id , sym:: unstable)
205+ }
206+
207+ fn is_external ( def_id : DefId ) -> bool {
208+ def_id. as_local ( ) . is_none ( )
201209}
0 commit comments