Skip to content

Commit ea82130

Browse files
committed
github feedback
1 parent 0d85ac1 commit ea82130

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

clippy_lints/src/pub_underscore_fields.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ use clippy_config::types::PubUnderscoreFieldsBehaviour;
22
use clippy_utils::attrs::is_doc_hidden;
33
use clippy_utils::diagnostics::span_lint_and_help;
44
use clippy_utils::is_path_lang_item;
5-
use clippy_utils::source::snippet_opt;
65
use rustc_hir::{FieldDef, Item, ItemKind, LangItem};
76
use rustc_lint::{LateContext, LateLintPass};
87
use rustc_session::impl_lint_pass;
9-
use rustc_span::Span;
108

119
declare_clippy_lint! {
1210
/// ### What it does
@@ -30,7 +28,7 @@ declare_clippy_lint! {
3028
/// }
3129
/// ```
3230
///
33-
/// // OR
31+
/// OR
3432
///
3533
/// ```rust
3634
/// struct FileHandle {
@@ -57,7 +55,10 @@ impl<'tcx> LateLintPass<'tcx> for PubUnderscoreFields {
5755

5856
let is_visible = |field: &FieldDef<'_>| match self.behavior {
5957
PubUnderscoreFieldsBehaviour::PublicallyExported => cx.effective_visibilities.is_reachable(field.def_id),
60-
PubUnderscoreFieldsBehaviour::AllPubFields => start_with_pub(cx, field.vis_span),
58+
PubUnderscoreFieldsBehaviour::AllPubFields => {
59+
// If there is a visibility span then the field is marked pub in some way.
60+
!field.vis_span.is_empty()
61+
},
6162
};
6263

6364
for field in variant_data.fields() {
@@ -80,9 +81,3 @@ impl<'tcx> LateLintPass<'tcx> for PubUnderscoreFields {
8081
}
8182
}
8283
}
83-
84-
fn start_with_pub(cx: &LateContext<'_>, span: Span) -> bool {
85-
snippet_opt(cx, span)
86-
.map(|s| s.as_str().starts_with("pub"))
87-
.unwrap_or(false)
88-
}

0 commit comments

Comments
 (0)