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! {
2828 /// ```no_run
2929 /// pub mod public_module {
3030 /// 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+ /// }
3341 /// }
3442 /// }
3543 /// ```
@@ -60,7 +68,7 @@ impl EarlyLintPass for FieldScopedVisibilityModifiers {
6068 field. vis . span ,
6169 "scoped visibility modifier on a field" ,
6270 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 " ,
6472 ) ;
6573 }
6674 }
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ error: scoped visibility modifier on a field
44LL | pub(crate) pub_crate_field: bool,
55 | ^^^^^^^^^^
66 |
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
88 = note: `-D clippy::field-scoped-visibility-modifiers` implied by `-D warnings`
99 = help: to override `-D warnings` add `#[allow(clippy::field_scoped_visibility_modifiers)]`
1010
@@ -14,15 +14,15 @@ error: scoped visibility modifier on a field
1414LL | pub(in crate::pub_module) pub_in_path_field: bool,
1515 | ^^^^^^^^^^^^^^^^^^^^^^^^^
1616 |
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
1818
1919error: scoped visibility modifier on a field
2020 --> tests/ui/field_scoped_visibility_modifiers.rs:11:9
2121 |
2222LL | pub(super) pub_super_field: bool,
2323 | ^^^^^^^^^^
2424 |
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
2626
2727error: aborting due to 3 previous errors
2828
You can’t perform that action at this time.
0 commit comments