Skip to content

Commit 57b2ef6

Browse files
committed
polish
1 parent 6fb0fa0 commit 57b2ef6

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

clippy_lints/src/pub_underscore_fields.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use clippy_utils::attrs::is_doc_hidden;
22
use clippy_utils::diagnostics::span_lint_and_help;
33
use clippy_utils::is_path_lang_item;
4-
// use rustc_ast::ast::{Item, ItemKind, VisibilityKind};
54
use rustc_hir::{FieldDef, Item, ItemKind, LangItem};
65
use rustc_lint::{LateContext, LateLintPass};
76
use rustc_middle::ty::Visibility;
@@ -31,7 +30,7 @@ declare_clippy_lint! {
3130
///
3231
/// // OR
3332
///
34-
/// ```
33+
/// ```rust
3534
/// struct FileHandle {
3635
/// pub descriptor: usize,
3736
/// }
@@ -46,7 +45,7 @@ declare_lint_pass!(PubUnderscoreFields => [PUB_UNDERSCORE_FIELDS]);
4645
impl<'tcx> LateLintPass<'tcx> for PubUnderscoreFields {
4746
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
4847
// This lint only pertains to structs.
49-
let ItemKind::Struct(var, _) = &item.kind else {
48+
let ItemKind::Struct(variant_data, _) = &item.kind else {
5049
return;
5150
};
5251

@@ -61,9 +60,9 @@ impl<'tcx> LateLintPass<'tcx> for PubUnderscoreFields {
6160
case_1 || case_2
6261
};
6362

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)
6766
// We ignore fields that have `#[doc(hidden)]`.
6867
&& !is_doc_hidden(cx.tcx.hir().attrs(field.hir_id))
6968
// We ignore fields that are `PhantomData`.

0 commit comments

Comments
 (0)