1
1
use clippy_utils:: attrs:: is_doc_hidden;
2
2
use clippy_utils:: diagnostics:: span_lint_and_help;
3
3
use clippy_utils:: is_path_lang_item;
4
- // use rustc_ast::ast::{Item, ItemKind, VisibilityKind};
5
4
use rustc_hir:: { FieldDef , Item , ItemKind , LangItem } ;
6
5
use rustc_lint:: { LateContext , LateLintPass } ;
7
6
use rustc_middle:: ty:: Visibility ;
@@ -31,7 +30,7 @@ declare_clippy_lint! {
31
30
///
32
31
/// // OR
33
32
///
34
- /// ```
33
+ /// ```rust
35
34
/// struct FileHandle {
36
35
/// pub descriptor: usize,
37
36
/// }
@@ -46,7 +45,7 @@ declare_lint_pass!(PubUnderscoreFields => [PUB_UNDERSCORE_FIELDS]);
46
45
impl < ' tcx > LateLintPass < ' tcx > for PubUnderscoreFields {
47
46
fn check_item ( & mut self , cx : & LateContext < ' tcx > , item : & ' tcx Item < ' _ > ) {
48
47
// This lint only pertains to structs.
49
- let ItemKind :: Struct ( var , _) = & item. kind else {
48
+ let ItemKind :: Struct ( variant_data , _) = & item. kind else {
50
49
return ;
51
50
} ;
52
51
@@ -61,9 +60,9 @@ impl<'tcx> LateLintPass<'tcx> for PubUnderscoreFields {
61
60
case_1 || case_2
62
61
} ;
63
62
64
- for field in var . fields ( ) {
65
- // Only pertains to fields that start with an underscore, and are visible publically .
66
- if field. ident . as_str ( ) . starts_with ( '_' ) && is_visible ( & field)
63
+ for field in variant_data . fields ( ) {
64
+ // Only pertains to fields that start with an underscore, and are public .
65
+ if field. ident . as_str ( ) . starts_with ( '_' ) && is_visible ( field)
67
66
// We ignore fields that have `#[doc(hidden)]`.
68
67
&& !is_doc_hidden ( cx. tcx . hir ( ) . attrs ( field. hir_id ) )
69
68
// We ignore fields that are `PhantomData`.
0 commit comments