Skip to content

Commit 5e154fa

Browse files
Add tests for rustdoc --check option
1 parent a51b130 commit 5e154fa

File tree

5 files changed

+124
-0
lines changed

5 files changed

+124
-0
lines changed

src/test/rustdoc-ui/check-fail.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// compile-flags: -Z unstable-options --check
2+
3+
#![deny(missing_docs)]
4+
//~^ ERROR
5+
//~^^ ERROR
6+
#![deny(rustdoc)]
7+
8+
pub fn foo() {}
9+
//~^ ERROR
10+
//~^^ ERROR

src/test/rustdoc-ui/check-fail.stderr

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
error: missing documentation for the crate
2+
--> $DIR/check-fail.rs:3:1
3+
|
4+
LL | / #![deny(missing_docs)]
5+
LL | |
6+
LL | |
7+
LL | | #![deny(rustdoc)]
8+
LL | |
9+
LL | | pub fn foo() {}
10+
| |_______________^
11+
|
12+
note: the lint level is defined here
13+
--> $DIR/check-fail.rs:3:9
14+
|
15+
LL | #![deny(missing_docs)]
16+
| ^^^^^^^^^^^^
17+
18+
error: missing documentation for a function
19+
--> $DIR/check-fail.rs:8:1
20+
|
21+
LL | pub fn foo() {}
22+
| ^^^^^^^^^^^^
23+
24+
error: missing code example in this documentation
25+
--> $DIR/check-fail.rs:3:1
26+
|
27+
LL | / #![deny(missing_docs)]
28+
LL | |
29+
LL | |
30+
LL | | #![deny(rustdoc)]
31+
LL | |
32+
LL | | pub fn foo() {}
33+
| |_______________^
34+
|
35+
note: the lint level is defined here
36+
--> $DIR/check-fail.rs:6:9
37+
|
38+
LL | #![deny(rustdoc)]
39+
| ^^^^^^^
40+
= note: `#[deny(missing_doc_code_examples)]` implied by `#[deny(rustdoc)]`
41+
42+
error: missing code example in this documentation
43+
--> $DIR/check-fail.rs:8:1
44+
|
45+
LL | pub fn foo() {}
46+
| ^^^^^^^^^^^^^^^
47+
48+
error: aborting due to 4 previous errors
49+

src/test/rustdoc-ui/check.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// check-pass
2+
// compile-flags: -Z unstable-options --check
3+
4+
#![warn(missing_docs)]
5+
//~^ WARN
6+
//~^^ WARN
7+
#![warn(rustdoc)]
8+
9+
pub fn foo() {}
10+
//~^ WARN
11+
//~^^ WARN

src/test/rustdoc-ui/check.stderr

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
warning: missing documentation for the crate
2+
--> $DIR/check.rs:4:1
3+
|
4+
LL | / #![warn(missing_docs)]
5+
LL | |
6+
LL | |
7+
LL | | #![warn(rustdoc)]
8+
LL | |
9+
LL | | pub fn foo() {}
10+
| |_______________^
11+
|
12+
note: the lint level is defined here
13+
--> $DIR/check.rs:4:9
14+
|
15+
LL | #![warn(missing_docs)]
16+
| ^^^^^^^^^^^^
17+
18+
warning: missing documentation for a function
19+
--> $DIR/check.rs:9:1
20+
|
21+
LL | pub fn foo() {}
22+
| ^^^^^^^^^^^^
23+
24+
warning: missing code example in this documentation
25+
--> $DIR/check.rs:4:1
26+
|
27+
LL | / #![warn(missing_docs)]
28+
LL | |
29+
LL | |
30+
LL | | #![warn(rustdoc)]
31+
LL | |
32+
LL | | pub fn foo() {}
33+
| |_______________^
34+
|
35+
note: the lint level is defined here
36+
--> $DIR/check.rs:7:9
37+
|
38+
LL | #![warn(rustdoc)]
39+
| ^^^^^^^
40+
= note: `#[warn(missing_doc_code_examples)]` implied by `#[warn(rustdoc)]`
41+
42+
warning: missing code example in this documentation
43+
--> $DIR/check.rs:9:1
44+
|
45+
LL | pub fn foo() {}
46+
| ^^^^^^^^^^^^^^^
47+
48+
warning: 4 warnings emitted
49+

src/test/rustdoc/check.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// compile-flags: -Z unstable-options --check
2+
3+
// @!has check/fn.foo.html
4+
// @!has check/index.html
5+
pub fn foo() {}

0 commit comments

Comments
 (0)