Skip to content

Commit c283906

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

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

clippy_lints/src/pub_underscore_fields.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ declare_clippy_lint! {
2323
/// struct FileHandle {
2424
/// _descriptor: usize,
2525
/// }
26+
/// // OR
27+
/// struct FileHandle {
28+
/// pub descriptor: usize,
29+
/// }
2630
/// ```
2731
#[clippy::version = "1.74.0"]
2832
pub PUB_UNDERSCORE_FIELDS,
@@ -38,16 +42,15 @@ impl EarlyLintPass for PubUnderscoreFields {
3842
return;
3943
};
4044

41-
let msg = "field marked as public but also inferred as unused because it's prefixed with `_`";
42-
for field in st.fields().iter() {
45+
for field in st.fields() {
4346
if let Some(ident) = field.ident.as_ref()
4447
&& ident.as_str().starts_with('_')
4548
&& !matches!(field.vis.kind, VisibilityKind::Inherited) {
4649
span_lint_and_help(
4750
cx,
4851
PUB_UNDERSCORE_FIELDS,
4952
field.vis.span.to(ident.span),
50-
msg,
53+
"field marked as public but also inferred as unused because it's prefixed with `_`",
5154
None,
5255
"consider removing the underscore, or making the field private",
5356
);

0 commit comments

Comments
 (0)