suggest removing a semicolon after derive attributes
use current token span
This commit is contained in:
parent
06460fe72c
commit
47d91bc9e6
@ -449,6 +449,16 @@ impl<'a> Parser<'a> {
|
||||
if end.is_doc_comment() {
|
||||
err.span_label(end.span, "this doc comment doesn't document anything");
|
||||
}
|
||||
if end.meta_kind().is_some() {
|
||||
if self.token.kind == TokenKind::Semi {
|
||||
err.span_suggestion_verbose(
|
||||
self.token.span,
|
||||
"consider removing this semicolon",
|
||||
String::new(),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
}
|
||||
}
|
||||
if let [.., penultimate, _] = attrs {
|
||||
err.span_label(start.span.to(penultimate.span), "other attributes here");
|
||||
}
|
||||
|
4
src/test/ui/parser/attr-with-a-semicolon.rs
Normal file
4
src/test/ui/parser/attr-with-a-semicolon.rs
Normal file
@ -0,0 +1,4 @@
|
||||
#[derive(Debug, Clone)]; //~ERROR expected item after attributes
|
||||
struct Foo;
|
||||
|
||||
fn main() {}
|
14
src/test/ui/parser/attr-with-a-semicolon.stderr
Normal file
14
src/test/ui/parser/attr-with-a-semicolon.stderr
Normal file
@ -0,0 +1,14 @@
|
||||
error: expected item after attributes
|
||||
--> $DIR/attr-with-a-semicolon.rs:1:1
|
||||
|
|
||||
LL | #[derive(Debug, Clone)];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: consider removing this semicolon
|
||||
|
|
||||
LL - #[derive(Debug, Clone)];
|
||||
LL + #[derive(Debug, Clone)]
|
||||
|
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
x
Reference in New Issue
Block a user