From 3d16f476fa1c424d00dc323aeea2058df5296c23 Mon Sep 17 00:00:00 2001 From: Parker Timmerman Date: Tue, 10 Oct 2023 23:21:36 -0400 Subject: [PATCH] responding to feedback, inline msg, update comments --- clippy_lints/src/pub_underscore_fields.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/clippy_lints/src/pub_underscore_fields.rs b/clippy_lints/src/pub_underscore_fields.rs index e0d341e0db89..87e93060a4ca 100644 --- a/clippy_lints/src/pub_underscore_fields.rs +++ b/clippy_lints/src/pub_underscore_fields.rs @@ -20,9 +20,15 @@ declare_clippy_lint! { /// ``` /// Use instead: /// ```rust - /// struct FileHandle { + /// struct FileHandle_Foo { /// _descriptor: usize, /// } + /// + /// // OR + /// + /// struct FileHandle_Bar { + /// pub descriptor: usize, + /// } /// ``` #[clippy::version = "1.74.0"] pub PUB_UNDERSCORE_FIELDS, @@ -38,8 +44,7 @@ impl EarlyLintPass for PubUnderscoreFields { return; }; - let msg = "field marked as public but also inferred as unused because it's prefixed with `_`"; - for field in st.fields().iter() { + for field in st.fields() { if let Some(ident) = field.ident.as_ref() && ident.as_str().starts_with('_') && !matches!(field.vis.kind, VisibilityKind::Inherited) { @@ -47,7 +52,7 @@ impl EarlyLintPass for PubUnderscoreFields { cx, PUB_UNDERSCORE_FIELDS, field.vis.span.to(ident.span), - msg, + "field marked as public but also inferred as unused because it's prefixed with `_`", None, "consider removing the underscore, or making the field private", );