-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #10303 - pvdrz:pub_crate_missing_docs, r=giraffate
Add configuration to lint missing docs of `pub(crate)` items Fixes this: #5736 (comment) TODO: - [x] Needs docs - [x] Needs better names - [x] Should `pub` items be checked to when this new option is enabled? I'm saying no because `missing_docs` already exists `@flip1995` I'd like to get some input from you :) --- changelog: Enhancement: [`missing_docs_in_private_items`]: Added new configuration `missing-docs-in-crate-items` to lint on items visible within the current crate. For example, `pub(crate)` items. [#10303](#10303) <!-- changelog_checked -->
- Loading branch information
Showing
8 changed files
with
152 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
missing-docs-in-crate-items = true |
59 changes: 59 additions & 0 deletions
59
tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//! this is crate | ||
#![allow(missing_docs)] | ||
#![warn(clippy::missing_docs_in_private_items)] | ||
|
||
/// this is mod | ||
mod my_mod { | ||
/// some docs | ||
fn priv_with_docs() {} | ||
fn priv_no_docs() {} | ||
/// some docs | ||
pub(crate) fn crate_with_docs() {} | ||
pub(crate) fn crate_no_docs() {} | ||
/// some docs | ||
pub(super) fn super_with_docs() {} | ||
pub(super) fn super_no_docs() {} | ||
|
||
mod my_sub { | ||
/// some docs | ||
fn sub_priv_with_docs() {} | ||
fn sub_priv_no_docs() {} | ||
/// some docs | ||
pub(crate) fn sub_crate_with_docs() {} | ||
pub(crate) fn sub_crate_no_docs() {} | ||
/// some docs | ||
pub(super) fn sub_super_with_docs() {} | ||
pub(super) fn sub_super_no_docs() {} | ||
} | ||
|
||
/// some docs | ||
pub(crate) struct CrateStructWithDocs { | ||
/// some docs | ||
pub(crate) crate_field_with_docs: (), | ||
pub(crate) crate_field_no_docs: (), | ||
/// some docs | ||
priv_field_with_docs: (), | ||
priv_field_no_docs: (), | ||
} | ||
|
||
pub(crate) struct CrateStructNoDocs { | ||
/// some docs | ||
pub(crate) crate_field_with_docs: (), | ||
pub(crate) crate_field_no_docs: (), | ||
/// some docs | ||
priv_field_with_docs: (), | ||
priv_field_no_docs: (), | ||
} | ||
} | ||
|
||
/// some docs | ||
type CrateTypedefWithDocs = String; | ||
type CrateTypedefNoDocs = String; | ||
/// some docs | ||
pub type PubTypedefWithDocs = String; | ||
pub type PubTypedefNoDocs = String; | ||
|
||
fn main() { | ||
my_mod::crate_with_docs(); | ||
my_mod::crate_no_docs(); | ||
} |
52 changes: 52 additions & 0 deletions
52
tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
error: missing documentation for a function | ||
--> $DIR/pub_crate_missing_doc.rs:12:5 | ||
| | ||
LL | pub(crate) fn crate_no_docs() {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `-D clippy::missing-docs-in-private-items` implied by `-D warnings` | ||
|
||
error: missing documentation for a function | ||
--> $DIR/pub_crate_missing_doc.rs:15:5 | ||
| | ||
LL | pub(super) fn super_no_docs() {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: missing documentation for a function | ||
--> $DIR/pub_crate_missing_doc.rs:23:9 | ||
| | ||
LL | pub(crate) fn sub_crate_no_docs() {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: missing documentation for a struct field | ||
--> $DIR/pub_crate_missing_doc.rs:33:9 | ||
| | ||
LL | pub(crate) crate_field_no_docs: (), | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: missing documentation for a struct | ||
--> $DIR/pub_crate_missing_doc.rs:39:5 | ||
| | ||
LL | / pub(crate) struct CrateStructNoDocs { | ||
LL | | /// some docs | ||
LL | | pub(crate) crate_field_with_docs: (), | ||
LL | | pub(crate) crate_field_no_docs: (), | ||
... | | ||
LL | | priv_field_no_docs: (), | ||
LL | | } | ||
| |_____^ | ||
|
||
error: missing documentation for a struct field | ||
--> $DIR/pub_crate_missing_doc.rs:42:9 | ||
| | ||
LL | pub(crate) crate_field_no_docs: (), | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: missing documentation for a type alias | ||
--> $DIR/pub_crate_missing_doc.rs:51:1 | ||
| | ||
LL | type CrateTypedefNoDocs = String; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 7 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters