Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdrz committed Feb 17, 2023
1 parent 64b8aaf commit c29e767
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/missing_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl MissingDoc {

if self.crate_items_only && def_id != CRATE_DEF_ID {
let vis = cx.tcx.visibility(def_id);
if vis != Visibility::Public && vis != Visibility::Restricted(CRATE_DEF_ID.into()) {
if vis == Visibility::Public || vis != Visibility::Restricted(CRATE_DEF_ID.into()) {
return;
}
}
Expand Down
3 changes: 2 additions & 1 deletion clippy_lints/src/utils/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,8 @@ define_Conf! {
(suppress_restriction_lint_in_const: bool = false),
/// Lint: MISSING_DOCS_IN_PRIVATE_ITEMS.
///
/// Whether to **only** check for missing documentation in `pub(crate)` items.
/// Whether to **only** check for missing documentation in items visible within the current
/// crate. For example, `pub(crate)` items.
(missing_docs_in_crate_items: bool = false),
}

Expand Down
8 changes: 8 additions & 0 deletions tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! this is crate
#![allow(missing_docs)]
#![warn(clippy::missing_docs_in_private_items)]

/// this is mod
Expand Down Expand Up @@ -45,6 +46,13 @@ mod my_mod {
}
}

/// 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();
Expand Down
20 changes: 13 additions & 7 deletions tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
error: missing documentation for a function
--> $DIR/pub_crate_missing_doc.rs:11:5
--> $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:14:5
--> $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:22:9
--> $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:32:9
--> $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:38:5
--> $DIR/pub_crate_missing_doc.rs:39:5
|
LL | / pub(crate) struct CrateStructNoDocs {
LL | | /// some docs
Expand All @@ -37,10 +37,16 @@ LL | | }
| |_____^

error: missing documentation for a struct field
--> $DIR/pub_crate_missing_doc.rs:41:9
--> $DIR/pub_crate_missing_doc.rs:42:9
|
LL | pub(crate) crate_field_no_docs: (),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 6 previous errors
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

0 comments on commit c29e767

Please sign in to comment.