Skip to content

Commit

Permalink
Improve 'use instead' section of lint doc
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleoneill committed Jun 16, 2024
1 parent e89a9ea commit ff7e472
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 11 additions & 3 deletions clippy_lints/src/field_scoped_visibility_modifiers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,16 @@ declare_clippy_lint! {
/// ```no_run
/// pub mod public_module {
/// struct MyStruct {
/// pub first_field: bool,
/// pub second_field: bool
/// first_field: bool,
/// second_field: bool
/// }
/// impl MyStruct {
/// pub(crate) fn get_first_field(&self) -> bool {
/// self.first_field
/// }
/// pub(super) fn get_second_field(&self) -> bool {
/// self.second_field
/// }
/// }
/// }
/// ```
Expand Down Expand Up @@ -60,7 +68,7 @@ impl EarlyLintPass for FieldScopedVisibilityModifiers {
field.vis.span,
"scoped visibility modifier on a field",
None,
"consider making the field either public or private",
"consider making the field private and adding a scoped visibility method to read it",
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/field_scoped_visibility_modifiers.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error: scoped visibility modifier on a field
LL | pub(crate) pub_crate_field: bool,
| ^^^^^^^^^^
|
= help: consider making the field either public or private
= help: consider making the field private and adding a scoped visibility method to read it
= note: `-D clippy::field-scoped-visibility-modifiers` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::field_scoped_visibility_modifiers)]`

Expand All @@ -14,15 +14,15 @@ error: scoped visibility modifier on a field
LL | pub(in crate::pub_module) pub_in_path_field: bool,
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider making the field either public or private
= help: consider making the field private and adding a scoped visibility method to read it

error: scoped visibility modifier on a field
--> tests/ui/field_scoped_visibility_modifiers.rs:11:9
|
LL | pub(super) pub_super_field: bool,
| ^^^^^^^^^^
|
= help: consider making the field either public or private
= help: consider making the field private and adding a scoped visibility method to read it

error: aborting due to 3 previous errors

0 comments on commit ff7e472

Please sign in to comment.