File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -28,8 +28,16 @@ declare_clippy_lint! {
28
28
/// ```no_run
29
29
/// pub mod public_module {
30
30
/// struct MyStruct {
31
- /// pub first_field: bool,
32
- /// pub second_field: bool
31
+ /// first_field: bool,
32
+ /// second_field: bool
33
+ /// }
34
+ /// impl MyStruct {
35
+ /// pub(crate) fn get_first_field(&self) -> bool {
36
+ /// self.first_field
37
+ /// }
38
+ /// pub(super) fn get_second_field(&self) -> bool {
39
+ /// self.second_field
40
+ /// }
33
41
/// }
34
42
/// }
35
43
/// ```
@@ -60,7 +68,7 @@ impl EarlyLintPass for FieldScopedVisibilityModifiers {
60
68
field. vis . span ,
61
69
"scoped visibility modifier on a field" ,
62
70
None ,
63
- "consider making the field either public or private " ,
71
+ "consider making the field private and adding a scoped visibility method to read it " ,
64
72
) ;
65
73
}
66
74
}
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ error: scoped visibility modifier on a field
4
4
LL | pub(crate) pub_crate_field: bool,
5
5
| ^^^^^^^^^^
6
6
|
7
- = help: consider making the field either public or private
7
+ = help: consider making the field private and adding a scoped visibility method to read it
8
8
= note: `-D clippy::field-scoped-visibility-modifiers` implied by `-D warnings`
9
9
= help: to override `-D warnings` add `#[allow(clippy::field_scoped_visibility_modifiers)]`
10
10
@@ -14,15 +14,15 @@ error: scoped visibility modifier on a field
14
14
LL | pub(in crate::pub_module) pub_in_path_field: bool,
15
15
| ^^^^^^^^^^^^^^^^^^^^^^^^^
16
16
|
17
- = help: consider making the field either public or private
17
+ = help: consider making the field private and adding a scoped visibility method to read it
18
18
19
19
error: scoped visibility modifier on a field
20
20
--> tests/ui/field_scoped_visibility_modifiers.rs:11:9
21
21
|
22
22
LL | pub(super) pub_super_field: bool,
23
23
| ^^^^^^^^^^
24
24
|
25
- = help: consider making the field either public or private
25
+ = help: consider making the field private and adding a scoped visibility method to read it
26
26
27
27
error: aborting due to 3 previous errors
28
28
You can’t perform that action at this time.
0 commit comments