Skip to content

Commit 1cbc945

Browse files
Add ui test for check_private_items config
1 parent 8ed4add commit 1cbc945

File tree

3 files changed

+119
-0
lines changed

3 files changed

+119
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
check-private-items = true
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#![deny(
2+
clippy::unnecessary_safety_doc,
3+
clippy::missing_errors_doc,
4+
clippy::missing_panics_doc
5+
)]
6+
7+
/// This is a private function, skip to match behavior with `missing_safety_doc`.
8+
///
9+
/// # Safety
10+
///
11+
/// Boo!
12+
fn you_dont_see_me() {
13+
//~^ ERROR: safe function's docs have unnecessary `# Safety` section
14+
unimplemented!();
15+
}
16+
17+
mod private_mod {
18+
/// This is public but unexported function.
19+
///
20+
/// # Safety
21+
///
22+
/// Very safe!
23+
pub fn only_crate_wide_accessible() -> Result<(), ()> {
24+
//~^ ERROR: safe function's docs have unnecessary `# Safety` section
25+
//~| ERROR: docs for function returning `Result` missing `# Errors` section
26+
unimplemented!();
27+
}
28+
}
29+
30+
pub struct S;
31+
32+
impl S {
33+
/// Private, fine again to stay consistent with `missing_safety_doc`.
34+
///
35+
/// # Safety
36+
///
37+
/// Unnecessary!
38+
fn private(&self) {
39+
//~^ ERROR: safe function's docs have unnecessary `# Safety` section
40+
//~| ERROR: docs for function which may panic missing `# Panics` section
41+
panic!();
42+
}
43+
}
44+
45+
#[doc(hidden)]
46+
pub mod __macro {
47+
pub struct T;
48+
impl T {
49+
pub unsafe fn f() {}
50+
//~^ ERROR: unsafe function's docs miss `# Safety` section
51+
}
52+
}
53+
54+
fn main() {}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
error: safe function's docs have unnecessary `# Safety` section
2+
--> $DIR/doc_lints.rs:12:1
3+
|
4+
LL | fn you_dont_see_me() {
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/doc_lints.rs:2:5
9+
|
10+
LL | clippy::unnecessary_safety_doc,
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error: safe function's docs have unnecessary `# Safety` section
14+
--> $DIR/doc_lints.rs:23:5
15+
|
16+
LL | pub fn only_crate_wide_accessible() -> Result<(), ()> {
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18+
19+
error: docs for function returning `Result` missing `# Errors` section
20+
--> $DIR/doc_lints.rs:23:5
21+
|
22+
LL | pub fn only_crate_wide_accessible() -> Result<(), ()> {
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24+
|
25+
note: the lint level is defined here
26+
--> $DIR/doc_lints.rs:3:5
27+
|
28+
LL | clippy::missing_errors_doc,
29+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
30+
31+
error: safe function's docs have unnecessary `# Safety` section
32+
--> $DIR/doc_lints.rs:38:5
33+
|
34+
LL | fn private(&self) {
35+
| ^^^^^^^^^^^^^^^^^
36+
37+
error: docs for function which may panic missing `# Panics` section
38+
--> $DIR/doc_lints.rs:38:5
39+
|
40+
LL | fn private(&self) {
41+
| ^^^^^^^^^^^^^^^^^
42+
|
43+
note: first possible panic found here
44+
--> $DIR/doc_lints.rs:41:9
45+
|
46+
LL | panic!();
47+
| ^^^^^^^^
48+
note: the lint level is defined here
49+
--> $DIR/doc_lints.rs:4:5
50+
|
51+
LL | clippy::missing_panics_doc
52+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
53+
54+
error: unsafe function's docs miss `# Safety` section
55+
--> $DIR/doc_lints.rs:49:9
56+
|
57+
LL | pub unsafe fn f() {}
58+
| ^^^^^^^^^^^^^^^^^
59+
|
60+
= note: `-D clippy::missing-safety-doc` implied by `-D warnings`
61+
= help: to override `-D warnings` add `#[allow(clippy::missing_safety_doc)]`
62+
63+
error: aborting due to 6 previous errors
64+

0 commit comments

Comments
 (0)