From c29e767ef1f2afc534c175f16fce5d671943fe4b Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Fri, 17 Feb 2023 09:09:44 -0500 Subject: [PATCH] Address review comments --- clippy_lints/src/missing_doc.rs | 2 +- clippy_lints/src/utils/conf.rs | 3 ++- .../pub_crate_missing_doc.rs | 8 ++++++++ .../pub_crate_missing_doc.stderr | 20 ++++++++++++------- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index a5d8a500cca..74592918bfc 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -103,7 +103,7 @@ fn check_missing_docs_attrs( 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; } } diff --git a/clippy_lints/src/utils/conf.rs b/clippy_lints/src/utils/conf.rs index ae35ceebc55..c3c73ac6e37 100644 --- a/clippy_lints/src/utils/conf.rs +++ b/clippy_lints/src/utils/conf.rs @@ -456,7 +456,8 @@ pub(crate) fn get_configuration_metadata() -> Vec { (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), } diff --git a/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.rs b/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.rs index f2edb737d59..830d71f61dd 100644 --- a/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.rs +++ b/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.rs @@ -1,4 +1,5 @@ //! this is crate +#![allow(missing_docs)] #![warn(clippy::missing_docs_in_private_items)] /// this is mod @@ -45,6 +46,13 @@ pub(crate) struct CrateStructNoDocs { } } +/// 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(); diff --git a/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr b/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr index 89927abd87b..a474187050c 100644 --- a/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr +++ b/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr @@ -1,5 +1,5 @@ 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() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,25 +7,25 @@ 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 @@ -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