Skip to content

Commit f48df4a

Browse files
committed
Add test doc-comment-after-comma-issue-142311.rs
Signed-off-by: xizheyin <[email protected]>
1 parent b6685d7 commit f48df4a

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//! Check that if the parser suggests converting `///` to a regular comment
2+
//! when it appears after a missing comma in an list (e.g. `enum` variants).
3+
//!
4+
//! Related issue
5+
//! - https://github.com/rust-lang/rust/issues/142311
6+
7+
enum Foo {
8+
/// Like the noise a sheep makes
9+
Bar
10+
/// Like where people drink
11+
//~^ ERROR expected one of `(`, `,`, `=`, `{`, or `}`, found doc comment `/// Like where people drink`
12+
Baa///xxxxxx
13+
//~^ ERROR expected one of `(`, `,`, `=`, `{`, or `}`, found doc comment `///xxxxxx`
14+
Baz///xxxxxx
15+
//~^ ERROR expected one of `(`, `,`, `=`, `{`, or `}`, found doc comment `///xxxxxx`
16+
}
17+
18+
fn foo() {
19+
let a = [
20+
1///xxxxxx
21+
//~^ ERROR expected one of `,`, `.`, `;`, `?`, `]`, or an operator, found doc comment `///xxxxxx`
22+
2
23+
];
24+
}
25+
26+
fn bar() {
27+
let a = [
28+
1,
29+
2///xxxxxx
30+
//~^ ERROR expected one of `,`, `.`, `?`, `]`, or an operator, found doc comment `///xxxxxx`
31+
];
32+
}
33+
34+
fn main() {}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
error: expected one of `(`, `,`, `=`, `{`, or `}`, found doc comment `/// Like where people drink`
2+
--> $DIR/doc-comment-after-missing-comma-issue-142311.rs:10:5
3+
|
4+
LL | Bar
5+
| - expected one of `(`, `,`, `=`, `{`, or `}`
6+
LL | /// Like where people drink
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ unexpected token
8+
|
9+
help: add a space before the last `/` to write a regular comment
10+
|
11+
LL | // / Like where people drink
12+
| +
13+
help: missing `,`
14+
|
15+
LL | Bar,
16+
| +
17+
18+
error: expected one of `(`, `,`, `=`, `{`, or `}`, found doc comment `///xxxxxx`
19+
--> $DIR/doc-comment-after-missing-comma-issue-142311.rs:12:8
20+
|
21+
LL | Baa///xxxxxx
22+
| ^^^^^^^^^ expected one of `(`, `,`, `=`, `{`, or `}`
23+
|
24+
help: add a space before the last `/` to write a regular comment
25+
|
26+
LL | Baa// /xxxxxx
27+
| +
28+
help: missing `,`
29+
|
30+
LL | Baa,///xxxxxx
31+
| +
32+
33+
error: expected one of `(`, `,`, `=`, `{`, or `}`, found doc comment `///xxxxxx`
34+
--> $DIR/doc-comment-after-missing-comma-issue-142311.rs:14:8
35+
|
36+
LL | Baz///xxxxxx
37+
| ^^^^^^^^^ expected one of `(`, `,`, `=`, `{`, or `}`
38+
|
39+
= help: doc comments must come before what they document, if a comment was intended use `//`
40+
= help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }`
41+
help: add a space before the last `/` to write a regular comment
42+
|
43+
LL | Baz// /xxxxxx
44+
| +
45+
46+
error: expected one of `,`, `.`, `;`, `?`, `]`, or an operator, found doc comment `///xxxxxx`
47+
--> $DIR/doc-comment-after-missing-comma-issue-142311.rs:20:10
48+
|
49+
LL | 1///xxxxxx
50+
| ^^^^^^^^^ expected one of `,`, `.`, `;`, `?`, `]`, or an operator
51+
|
52+
help: add a space before the last `/` to write a regular comment
53+
|
54+
LL | 1// /xxxxxx
55+
| +
56+
57+
error: expected one of `,`, `.`, `?`, `]`, or an operator, found doc comment `///xxxxxx`
58+
--> $DIR/doc-comment-after-missing-comma-issue-142311.rs:29:10
59+
|
60+
LL | 2///xxxxxx
61+
| ^^^^^^^^^ expected one of `,`, `.`, `?`, `]`, or an operator
62+
|
63+
help: add a space before the last `/` to write a regular comment
64+
|
65+
LL | 2// /xxxxxx
66+
| +
67+
68+
error: aborting due to 5 previous errors
69+

0 commit comments

Comments
 (0)