Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add . to end of lint lists in configuration + Fix typo in pub_underscore_fields_behavior #12144

Merged
merged 2 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions book/src/lint_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,8 @@ Additional dotfiles (files or directories starting with a dot) to allow


## `enforce-iter-loop-reborrow`
Whether to recommend using implicit into iter for reborrowed values.

#### Example
```no_run
let mut vec = vec![1, 2, 3];
Expand All @@ -793,7 +795,7 @@ for _ in &mut *rmvec {}


## `check-private-items`

Whether to also run the listed lints on private items.

**Default Value:** `false`

Expand All @@ -806,9 +808,10 @@ for _ in &mut *rmvec {}


## `pub-underscore-fields-behavior`
Lint "public" fields in a struct that are prefixed with an underscore based on their
exported visibility, or whether they are marked as "pub".


**Default Value:** `"PublicallyExported"`
**Default Value:** `"PubliclyExported"`

---
**Affected lints:**
Expand Down
8 changes: 4 additions & 4 deletions clippy_config/src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ define_Conf! {
///
/// Additional dotfiles (files or directories starting with a dot) to allow
(allowed_dotfiles: FxHashSet<String> = FxHashSet::default()),
/// Lint: EXPLICIT_ITER_LOOP
/// Lint: EXPLICIT_ITER_LOOP.
///
/// Whether to recommend using implicit into iter for reborrowed values.
///
Expand All @@ -543,15 +543,15 @@ define_Conf! {
/// for _ in &mut *rmvec {}
/// ```
(enforce_iter_loop_reborrow: bool = false),
/// Lint: MISSING_SAFETY_DOC, UNNECESSARY_SAFETY_DOC, MISSING_PANICS_DOC, MISSING_ERRORS_DOC
/// Lint: MISSING_SAFETY_DOC, UNNECESSARY_SAFETY_DOC, MISSING_PANICS_DOC, MISSING_ERRORS_DOC.
///
/// Whether to also run the listed lints on private items.
(check_private_items: bool = false),
/// Lint: PUB_UNDERSCORE_FIELDS
/// Lint: PUB_UNDERSCORE_FIELDS.
///
/// Lint "public" fields in a struct that are prefixed with an underscore based on their
/// exported visibility, or whether they are marked as "pub".
(pub_underscore_fields_behavior: PubUnderscoreFieldsBehaviour = PubUnderscoreFieldsBehaviour::PublicallyExported),
(pub_underscore_fields_behavior: PubUnderscoreFieldsBehaviour = PubUnderscoreFieldsBehaviour::PubliclyExported),
}

/// Search for the configuration file.
Expand Down
2 changes: 1 addition & 1 deletion clippy_config/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,6 @@ unimplemented_serialize! {

#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)]
pub enum PubUnderscoreFieldsBehaviour {
PublicallyExported,
PubliclyExported,
AllPubFields,
}
2 changes: 1 addition & 1 deletion clippy_lints/src/pub_underscore_fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<'tcx> LateLintPass<'tcx> for PubUnderscoreFields {
};

let is_visible = |field: &FieldDef<'_>| match self.behavior {
PubUnderscoreFieldsBehaviour::PublicallyExported => cx.effective_visibilities.is_reachable(field.def_id),
PubUnderscoreFieldsBehaviour::PubliclyExported => cx.effective_visibilities.is_reachable(field.def_id),
PubUnderscoreFieldsBehaviour::AllPubFields => {
// If there is a visibility span then the field is marked pub in some way.
!field.vis_span.is_empty()
Expand Down
2 changes: 1 addition & 1 deletion tests/ui-toml/pub_underscore_fields/exported/clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub-underscore-fields-behavior = "PublicallyExported"
pub-underscore-fields-behavior = "PubliclyExported"