Skip to content

Commit a06fd1f

Browse files
Ensure that INVALID_CODEBLOCK_ATTRIBUTES lint is emitted
1 parent 5e154fa commit a06fd1f

File tree

2 files changed

+47
-28
lines changed

2 files changed

+47
-28
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
// compile-flags: -Z unstable-options --check
22

33
#![deny(missing_docs)]
4-
//~^ ERROR
5-
//~^^ ERROR
64
#![deny(rustdoc)]
75

6+
//! ```rust,testharness
7+
//~^ ERROR
8+
//! let x = 12;
9+
//! ```
10+
811
pub fn foo() {}
912
//~^ ERROR
1013
//~^^ ERROR
14+
15+
/// hello
16+
//~^ ERROR
17+
///
18+
/// ```rust,testharness
19+
/// let x = 12;
20+
/// ```
21+
pub fn bar() {}

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

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,57 @@
1-
error: missing documentation for the crate
2-
--> $DIR/check-fail.rs:3:1
1+
error: missing documentation for a function
2+
--> $DIR/check-fail.rs:11:1
33
|
4-
LL | / #![deny(missing_docs)]
5-
LL | |
6-
LL | |
7-
LL | | #![deny(rustdoc)]
8-
LL | |
9-
LL | | pub fn foo() {}
10-
| |_______________^
4+
LL | pub fn foo() {}
5+
| ^^^^^^^^^^^^
116
|
127
note: the lint level is defined here
138
--> $DIR/check-fail.rs:3:9
149
|
1510
LL | #![deny(missing_docs)]
1611
| ^^^^^^^^^^^^
1712

18-
error: missing documentation for a function
19-
--> $DIR/check-fail.rs:8:1
13+
error: missing code example in this documentation
14+
--> $DIR/check-fail.rs:11:1
2015
|
2116
LL | pub fn foo() {}
22-
| ^^^^^^^^^^^^
17+
| ^^^^^^^^^^^^^^^
18+
|
19+
note: the lint level is defined here
20+
--> $DIR/check-fail.rs:4:9
21+
|
22+
LL | #![deny(rustdoc)]
23+
| ^^^^^^^
24+
= note: `#[deny(missing_doc_code_examples)]` implied by `#[deny(rustdoc)]`
2325

24-
error: missing code example in this documentation
25-
--> $DIR/check-fail.rs:3:1
26+
error: unknown attribute `testharness`. Did you mean `test_harness`?
27+
--> $DIR/check-fail.rs:6:1
2628
|
27-
LL | / #![deny(missing_docs)]
28-
LL | |
29-
LL | |
30-
LL | | #![deny(rustdoc)]
29+
LL | / //! ```rust,testharness
3130
LL | |
32-
LL | | pub fn foo() {}
33-
| |_______________^
31+
LL | | //! let x = 12;
32+
LL | | //! ```
33+
| |_______^
3434
|
3535
note: the lint level is defined here
36-
--> $DIR/check-fail.rs:6:9
36+
--> $DIR/check-fail.rs:4:9
3737
|
3838
LL | #![deny(rustdoc)]
3939
| ^^^^^^^
40-
= note: `#[deny(missing_doc_code_examples)]` implied by `#[deny(rustdoc)]`
40+
= note: `#[deny(invalid_codeblock_attributes)]` implied by `#[deny(rustdoc)]`
41+
= help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function
4142

42-
error: missing code example in this documentation
43-
--> $DIR/check-fail.rs:8:1
43+
error: unknown attribute `testharness`. Did you mean `test_harness`?
44+
--> $DIR/check-fail.rs:15:1
4445
|
45-
LL | pub fn foo() {}
46-
| ^^^^^^^^^^^^^^^
46+
LL | / /// hello
47+
LL | |
48+
LL | | ///
49+
LL | | /// ```rust,testharness
50+
LL | | /// let x = 12;
51+
LL | | /// ```
52+
| |_______^
53+
|
54+
= help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function
4755

4856
error: aborting due to 4 previous errors
4957

0 commit comments

Comments
 (0)