Skip to content

Commit

Permalink
Auto merge of #12144 - blyxyas:10283-postfix, r=llogiq
Browse files Browse the repository at this point in the history
Add . to end of lint lists in configuration + Fix typo in pub_underscore_fields_behavior

Fixes #10283 (comment)

In the "/// Lint: " list on each configuration option, you have to end with a dot. If the lint list doesn't have a dot, the configuration won't have documentation.

This PR adds those missing dots in some of the configuration, thus also adding their documentation.

changelog: Fix bug where a lot of config documentation wasn't showing.
changelog: Fix typo in `pub_underscore_fields_behavior` (`PublicallyExported` -> `PubliclyExported`)
  • Loading branch information
bors committed Jan 20, 2024
2 parents 70573af + 44f5d96 commit fe3e682
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
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"

0 comments on commit fe3e682

Please sign in to comment.