Skip to content

Commit 3d16f47

Browse files
committed
responding to feedback, inline msg, update comments
1 parent da69c5e commit 3d16f47

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

clippy_lints/src/pub_underscore_fields.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ declare_clippy_lint! {
2020
/// ```
2121
/// Use instead:
2222
/// ```rust
23-
/// struct FileHandle {
23+
/// struct FileHandle_Foo {
2424
/// _descriptor: usize,
2525
/// }
26+
///
27+
/// // OR
28+
///
29+
/// struct FileHandle_Bar {
30+
/// pub descriptor: usize,
31+
/// }
2632
/// ```
2733
#[clippy::version = "1.74.0"]
2834
pub PUB_UNDERSCORE_FIELDS,
@@ -38,16 +44,15 @@ impl EarlyLintPass for PubUnderscoreFields {
3844
return;
3945
};
4046

41-
let msg = "field marked as public but also inferred as unused because it's prefixed with `_`";
42-
for field in st.fields().iter() {
47+
for field in st.fields() {
4348
if let Some(ident) = field.ident.as_ref()
4449
&& ident.as_str().starts_with('_')
4550
&& !matches!(field.vis.kind, VisibilityKind::Inherited) {
4651
span_lint_and_help(
4752
cx,
4853
PUB_UNDERSCORE_FIELDS,
4954
field.vis.span.to(ident.span),
50-
msg,
55+
"field marked as public but also inferred as unused because it's prefixed with `_`",
5156
None,
5257
"consider removing the underscore, or making the field private",
5358
);

0 commit comments

Comments
 (0)