Skip to content

Commit 96a352e

Browse files
Add UI tests for new rustdoc lint
1 parent c687d04 commit 96a352e

File tree

4 files changed

+493
-0
lines changed

4 files changed

+493
-0
lines changed
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// compile-flags:--test
2+
3+
#![deny(invalid_codeblock_attribute)]
4+
5+
/// foo
6+
///
7+
/// ```compile-fail,compilefail,comPile_fail
8+
/// boo
9+
/// ```
10+
pub fn foo() {}
11+
12+
/// bar
13+
///
14+
/// ```should-panic,shouldpanic,shOuld_panic
15+
/// boo
16+
/// ```
17+
pub fn bar() {}
18+
19+
/// foobar
20+
///
21+
/// ```no-run,norun,nO_run
22+
/// boo
23+
/// ```
24+
pub fn foobar() {}
25+
26+
/// barfoo
27+
///
28+
/// ```allow-fail,allowfail,allOw_fail
29+
/// boo
30+
/// ```
31+
pub fn barfoo() {}
32+
33+
/// b
34+
///
35+
/// ```test-harness,testharness,tesT_harness
36+
/// boo
37+
/// ```
38+
pub fn b() {}
+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
error: unknown attribute `compile-fail`. Did you mean `compile_fail`?
2+
--> $DIR/check-attr-test.rs:5:1
3+
|
4+
5 | / /// foo
5+
6 | | ///
6+
7 | | /// ```compile-fail,compilefail,comPile_fail
7+
8 | | /// boo
8+
9 | | /// ```
9+
| |_______^
10+
|
11+
note: the lint level is defined here
12+
--> $DIR/check-attr-test.rs:3:9
13+
|
14+
3 | #![deny(invalid_codeblock_attribute)]
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
16+
= help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully
17+
18+
error: unknown attribute `compilefail`. Did you mean `compile_fail`?
19+
--> $DIR/check-attr-test.rs:5:1
20+
|
21+
5 | / /// foo
22+
6 | | ///
23+
7 | | /// ```compile-fail,compilefail,comPile_fail
24+
8 | | /// boo
25+
9 | | /// ```
26+
| |_______^
27+
|
28+
= help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully
29+
30+
error: unknown attribute `comPile_fail`. Did you mean `compile_fail`?
31+
--> $DIR/check-attr-test.rs:5:1
32+
|
33+
5 | / /// foo
34+
6 | | ///
35+
7 | | /// ```compile-fail,compilefail,comPile_fail
36+
8 | | /// boo
37+
9 | | /// ```
38+
| |_______^
39+
|
40+
= help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully
41+
42+
error: unknown attribute `should-panic`. Did you mean `should_panic`?
43+
--> $DIR/check-attr-test.rs:12:1
44+
|
45+
12 | / /// bar
46+
13 | | ///
47+
14 | | /// ```should-panic,shouldpanic,shOuld_panic
48+
15 | | /// boo
49+
16 | | /// ```
50+
| |_______^
51+
|
52+
= help: the code block will either not be tested if not marked as a rust one or won't fail if it doesn't panic when running
53+
54+
error: unknown attribute `shouldpanic`. Did you mean `should_panic`?
55+
--> $DIR/check-attr-test.rs:12:1
56+
|
57+
12 | / /// bar
58+
13 | | ///
59+
14 | | /// ```should-panic,shouldpanic,shOuld_panic
60+
15 | | /// boo
61+
16 | | /// ```
62+
| |_______^
63+
|
64+
= help: the code block will either not be tested if not marked as a rust one or won't fail if it doesn't panic when running
65+
66+
error: unknown attribute `shOuld_panic`. Did you mean `should_panic`?
67+
--> $DIR/check-attr-test.rs:12:1
68+
|
69+
12 | / /// bar
70+
13 | | ///
71+
14 | | /// ```should-panic,shouldpanic,shOuld_panic
72+
15 | | /// boo
73+
16 | | /// ```
74+
| |_______^
75+
|
76+
= help: the code block will either not be tested if not marked as a rust one or won't fail if it doesn't panic when running
77+
78+
error: unknown attribute `no-run`. Did you mean `no_run`?
79+
--> $DIR/check-attr-test.rs:19:1
80+
|
81+
19 | / /// foobar
82+
20 | | ///
83+
21 | | /// ```no-run,norun,nO_run
84+
22 | | /// boo
85+
23 | | /// ```
86+
| |_______^
87+
|
88+
= help: the code block will either not be tested if not marked as a rust one or will be run (which you might not want)
89+
90+
error: unknown attribute `norun`. Did you mean `no_run`?
91+
--> $DIR/check-attr-test.rs:19:1
92+
|
93+
19 | / /// foobar
94+
20 | | ///
95+
21 | | /// ```no-run,norun,nO_run
96+
22 | | /// boo
97+
23 | | /// ```
98+
| |_______^
99+
|
100+
= help: the code block will either not be tested if not marked as a rust one or will be run (which you might not want)
101+
102+
error: unknown attribute `nO_run`. Did you mean `no_run`?
103+
--> $DIR/check-attr-test.rs:19:1
104+
|
105+
19 | / /// foobar
106+
20 | | ///
107+
21 | | /// ```no-run,norun,nO_run
108+
22 | | /// boo
109+
23 | | /// ```
110+
| |_______^
111+
|
112+
= help: the code block will either not be tested if not marked as a rust one or will be run (which you might not want)
113+
114+
error: unknown attribute `allow-fail`. Did you mean `allow_fail`?
115+
--> $DIR/check-attr-test.rs:26:1
116+
|
117+
26 | / /// barfoo
118+
27 | | ///
119+
28 | | /// ```allow-fail,allowfail,allOw_fail
120+
29 | | /// boo
121+
30 | | /// ```
122+
| |_______^
123+
|
124+
= help: the code block will either not be tested if not marked as a rust one or will be run (which you might not want)
125+
126+
error: unknown attribute `allowfail`. Did you mean `allow_fail`?
127+
--> $DIR/check-attr-test.rs:26:1
128+
|
129+
26 | / /// barfoo
130+
27 | | ///
131+
28 | | /// ```allow-fail,allowfail,allOw_fail
132+
29 | | /// boo
133+
30 | | /// ```
134+
| |_______^
135+
|
136+
= help: the code block will either not be tested if not marked as a rust one or will be run (which you might not want)
137+
138+
error: unknown attribute `allOw_fail`. Did you mean `allow_fail`?
139+
--> $DIR/check-attr-test.rs:26:1
140+
|
141+
26 | / /// barfoo
142+
27 | | ///
143+
28 | | /// ```allow-fail,allowfail,allOw_fail
144+
29 | | /// boo
145+
30 | | /// ```
146+
| |_______^
147+
|
148+
= help: the code block will either not be tested if not marked as a rust one or will be run (which you might not want)
149+
150+
error: unknown attribute `test-harness`. Did you mean `test_harness`?
151+
--> $DIR/check-attr-test.rs:33:1
152+
|
153+
33 | / /// b
154+
34 | | ///
155+
35 | | /// ```test-harness,testharness,tesT_harness
156+
36 | | /// boo
157+
37 | | /// ```
158+
| |_______^
159+
|
160+
= 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
161+
162+
error: unknown attribute `testharness`. Did you mean `test_harness`?
163+
--> $DIR/check-attr-test.rs:33:1
164+
|
165+
33 | / /// b
166+
34 | | ///
167+
35 | | /// ```test-harness,testharness,tesT_harness
168+
36 | | /// boo
169+
37 | | /// ```
170+
| |_______^
171+
|
172+
= 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
173+
174+
error: unknown attribute `tesT_harness`. Did you mean `test_harness`?
175+
--> $DIR/check-attr-test.rs:33:1
176+
|
177+
33 | / /// b
178+
34 | | ///
179+
35 | | /// ```test-harness,testharness,tesT_harness
180+
36 | | /// boo
181+
37 | | /// ```
182+
| |_______^
183+
|
184+
= 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
185+
186+
error: aborting due to 15 previous errors
187+

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

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#![deny(invalid_codeblock_attribute)]
2+
3+
/// foo
4+
//~^ ERROR
5+
//~^^ ERROR
6+
//~^^^ ERROR
7+
///
8+
/// ```compile-fail,compilefail,comPile_fail
9+
/// boo
10+
/// ```
11+
pub fn foo() {}
12+
13+
/// bar
14+
//~^ ERROR
15+
//~^^ ERROR
16+
//~^^^ ERROR
17+
///
18+
/// ```should-panic,shouldpanic,sHould_panic
19+
/// boo
20+
/// ```
21+
pub fn bar() {}
22+
23+
/// foobar
24+
//~^ ERROR
25+
//~^^ ERROR
26+
//~^^^ ERROR
27+
///
28+
/// ```no-run,norun,no_Run
29+
/// boo
30+
/// ```
31+
pub fn foobar() {}
32+
33+
/// barfoo
34+
//~^ ERROR
35+
//~^^ ERROR
36+
//~^^^ ERROR
37+
///
38+
/// ```allow-fail,allowfail,alLow_fail
39+
/// boo
40+
/// ```
41+
pub fn barfoo() {}
42+
43+
/// b
44+
//~^ ERROR
45+
//~^^ ERROR
46+
//~^^^ ERROR
47+
///
48+
/// ```test-harness,testharness,teSt_harness
49+
/// boo
50+
/// ```
51+
pub fn b() {}

0 commit comments

Comments
 (0)