Skip to content

Commit 03f4ee4

Browse files
committed
Change error into E0585
Signed-off-by: xizheyin <[email protected]>
1 parent 109da9a commit 03f4ee4

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

compiler/rustc_parse/src/parser/diagnostics.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,13 @@ impl<'a> Parser<'a> {
710710
} else {
711711
// For fine-grained suggestions, we should suggest to add a comma before the doc comment
712712
// like `expr, //!val`
713+
err.cancel();
714+
err = self.dcx().struct_span_err(
715+
self.token.span,
716+
"found a documentation comment that doesn't document anything",
717+
);
718+
err.code(rustc_errors::E0585);
719+
err.span_label(self.token.span, "this doc comment doesn't document anything");
713720
err.span_suggestion_verbose(
714721
self.prev_token.span.shrink_to_hi(),
715722
"missing `,` before the doc comment",

tests/ui/parser/doc-comment-after-missing-comma-issue-142311.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ enum Foo {
88
/// Like the noise a sheep makes
99
Bar
1010
/// Like where people drink
11-
//~^ ERROR expected one of `(`, `,`, `=`, `{`, or `}`, found doc comment `/// Like where people drink`
11+
//~^ ERROR found a documentation comment that doesn't document anything [E0585]
1212
Baa///xxxxxx
13-
//~^ ERROR expected one of `(`, `,`, `=`, `{`, or `}`, found doc comment `///xxxxxx`
13+
//~^ ERROR found a documentation comment that doesn't document anything [E0585]
1414
Baz///xxxxxx
15-
//~^ ERROR expected one of `(`, `,`, `=`, `{`, or `}`, found doc comment `///xxxxxx`
15+
//~^ ERROR found a documentation comment that doesn't document anything [E0585]
1616
}
1717

1818
fn main() {}
Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,41 @@
1-
error: expected one of `(`, `,`, `=`, `{`, or `}`, found doc comment `/// Like where people drink`
1+
error[E0585]: found a documentation comment that doesn't document anything
22
--> $DIR/doc-comment-after-missing-comma-issue-142311.rs:10:5
33
|
44
LL | Bar
55
| - expected one of `(`, `,`, `=`, `{`, or `}`
66
LL | /// Like where people drink
7-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ unexpected token
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
8+
| |
9+
| this doc comment doesn't document anything
10+
| unexpected token
811
|
912
help: missing `,` before the doc comment
1013
|
1114
LL | Bar,
1215
| +
1316

14-
error: expected one of `(`, `,`, `=`, `{`, or `}`, found doc comment `///xxxxxx`
17+
error[E0585]: found a documentation comment that doesn't document anything
1518
--> $DIR/doc-comment-after-missing-comma-issue-142311.rs:12:8
1619
|
1720
LL | Baa///xxxxxx
18-
| ^^^^^^^^^ expected one of `(`, `,`, `=`, `{`, or `}`
21+
| ^^^^^^^^^
22+
| |
23+
| this doc comment doesn't document anything
24+
| expected one of `(`, `,`, `=`, `{`, or `}`
1925
|
2026
help: missing `,` before the doc comment
2127
|
2228
LL | Baa, ///xxxxxx
2329
| +
2430

25-
error: expected one of `(`, `,`, `=`, `{`, or `}`, found doc comment `///xxxxxx`
31+
error[E0585]: found a documentation comment that doesn't document anything
2632
--> $DIR/doc-comment-after-missing-comma-issue-142311.rs:14:8
2733
|
2834
LL | Baz///xxxxxx
29-
| ^^^^^^^^^ expected one of `(`, `,`, `=`, `{`, or `}`
35+
| ^^^^^^^^^
36+
| |
37+
| this doc comment doesn't document anything
38+
| expected one of `(`, `,`, `=`, `{`, or `}`
3039
|
3140
= help: doc comments must come before what they document, if a comment was intended use `//`
3241
= help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }`
@@ -37,3 +46,4 @@ LL | Baz, ///xxxxxx
3746

3847
error: aborting due to 3 previous errors
3948

49+
For more information about this error, try `rustc --explain E0585`.

0 commit comments

Comments
 (0)