File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,10 @@ declare_clippy_lint! {
23
23
/// struct FileHandle {
24
24
/// _descriptor: usize,
25
25
/// }
26
+ /// // OR
27
+ /// struct FileHandle {
28
+ /// pub descriptor: usize,
29
+ /// }
26
30
/// ```
27
31
#[ clippy:: version = "1.74.0" ]
28
32
pub PUB_UNDERSCORE_FIELDS ,
@@ -38,16 +42,15 @@ impl EarlyLintPass for PubUnderscoreFields {
38
42
return ;
39
43
} ;
40
44
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 ( ) {
43
46
if let Some ( ident) = field. ident . as_ref ( )
44
47
&& ident. as_str ( ) . starts_with ( '_' )
45
48
&& !matches ! ( field. vis. kind, VisibilityKind :: Inherited ) {
46
49
span_lint_and_help (
47
50
cx,
48
51
PUB_UNDERSCORE_FIELDS ,
49
52
field. vis . span . to ( ident. span ) ,
50
- msg ,
53
+ "field marked as public but also inferred as unused because it's prefixed with `_`" ,
51
54
None ,
52
55
"consider removing the underscore, or making the field private" ,
53
56
) ;
You can’t perform that action at this time.
0 commit comments