Skip to content

Commit c29e767

Browse files
committed
Address review comments
1 parent 64b8aaf commit c29e767

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

clippy_lints/src/missing_doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl MissingDoc {
103103

104104
if self.crate_items_only && def_id != CRATE_DEF_ID {
105105
let vis = cx.tcx.visibility(def_id);
106-
if vis != Visibility::Public && vis != Visibility::Restricted(CRATE_DEF_ID.into()) {
106+
if vis == Visibility::Public || vis != Visibility::Restricted(CRATE_DEF_ID.into()) {
107107
return;
108108
}
109109
}

clippy_lints/src/utils/conf.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,8 @@ define_Conf! {
456456
(suppress_restriction_lint_in_const: bool = false),
457457
/// Lint: MISSING_DOCS_IN_PRIVATE_ITEMS.
458458
///
459-
/// Whether to **only** check for missing documentation in `pub(crate)` items.
459+
/// Whether to **only** check for missing documentation in items visible within the current
460+
/// crate. For example, `pub(crate)` items.
460461
(missing_docs_in_crate_items: bool = false),
461462
}
462463

tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! this is crate
2+
#![allow(missing_docs)]
23
#![warn(clippy::missing_docs_in_private_items)]
34

45
/// this is mod
@@ -45,6 +46,13 @@ mod my_mod {
4546
}
4647
}
4748

49+
/// some docs
50+
type CrateTypedefWithDocs = String;
51+
type CrateTypedefNoDocs = String;
52+
/// some docs
53+
pub type PubTypedefWithDocs = String;
54+
pub type PubTypedefNoDocs = String;
55+
4856
fn main() {
4957
my_mod::crate_with_docs();
5058
my_mod::crate_no_docs();
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
error: missing documentation for a function
2-
--> $DIR/pub_crate_missing_doc.rs:11:5
2+
--> $DIR/pub_crate_missing_doc.rs:12:5
33
|
44
LL | pub(crate) fn crate_no_docs() {}
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::missing-docs-in-private-items` implied by `-D warnings`
88

99
error: missing documentation for a function
10-
--> $DIR/pub_crate_missing_doc.rs:14:5
10+
--> $DIR/pub_crate_missing_doc.rs:15:5
1111
|
1212
LL | pub(super) fn super_no_docs() {}
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1414

1515
error: missing documentation for a function
16-
--> $DIR/pub_crate_missing_doc.rs:22:9
16+
--> $DIR/pub_crate_missing_doc.rs:23:9
1717
|
1818
LL | pub(crate) fn sub_crate_no_docs() {}
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2020

2121
error: missing documentation for a struct field
22-
--> $DIR/pub_crate_missing_doc.rs:32:9
22+
--> $DIR/pub_crate_missing_doc.rs:33:9
2323
|
2424
LL | pub(crate) crate_field_no_docs: (),
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2626

2727
error: missing documentation for a struct
28-
--> $DIR/pub_crate_missing_doc.rs:38:5
28+
--> $DIR/pub_crate_missing_doc.rs:39:5
2929
|
3030
LL | / pub(crate) struct CrateStructNoDocs {
3131
LL | | /// some docs
@@ -37,10 +37,16 @@ LL | | }
3737
| |_____^
3838

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

45-
error: aborting due to 6 previous errors
45+
error: missing documentation for a type alias
46+
--> $DIR/pub_crate_missing_doc.rs:51:1
47+
|
48+
LL | type CrateTypedefNoDocs = String;
49+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
50+
51+
error: aborting due to 7 previous errors
4652

0 commit comments

Comments
 (0)