@@ -3,6 +3,7 @@ use clippy_utils::ty::is_type_diagnostic_item;
3
3
use clippy_utils:: { is_refutable, peel_hir_pat_refs, recurse_or_patterns} ;
4
4
use rustc_errors:: Applicability ;
5
5
use rustc_hir:: def:: { CtorKind , DefKind , Res } ;
6
+ use rustc_hir:: def_id:: DefId ;
6
7
use rustc_hir:: { Arm , Expr , PatKind , PathSegment , QPath , Ty , TyKind } ;
7
8
use rustc_lint:: LateContext ;
8
9
use rustc_middle:: ty:: { self , VariantDef } ;
@@ -45,11 +46,11 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) {
45
46
46
47
// Accumulate the variants which should be put in place of the wildcard because they're not
47
48
// 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) ) ;
49
50
let mut missing_variants: Vec < _ > = adt_def
50
51
. variants ( )
51
52
. iter ( )
52
- . filter ( |x| !is_hidden_and_external ( cx, x) )
53
+ . filter ( |x| !is_external_and_hidden ( cx, x) )
53
54
. collect ( ) ;
54
55
55
56
let mut path_prefix = CommonPrefixSearcher :: None ;
@@ -195,7 +196,14 @@ impl<'a> CommonPrefixSearcher<'a> {
195
196
}
196
197
}
197
198
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 ( )
201
209
}
0 commit comments