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