Fix condition for "missing struct" diagnostic on tuple structs

The check previously matched this, and suggested adding a missing
`struct`:

pub Foo(...):

It was probably intended to match this instead (semicolon instead of
colon):

pub Foo(...);
This commit is contained in:
Xiretza 2022-10-06 18:35:53 +02:00
parent a84adba552
commit 0757d5f83f
8 changed files with 42 additions and 7 deletions

View File

@ -412,7 +412,7 @@ impl<'a> Parser<'a> {
} else if self.check(&token::OpenDelim(Delimiter::Brace)) {
self.bump(); // `{`
("fn", kw_name, false)
} else if self.check(&token::Colon) {
} else if self.check(&token::Semi) {
let kw = "struct";
(kw, kw, false)
} else {

View File

@ -2,7 +2,7 @@
mod foo {
pub bar();
//~^ ERROR missing `fn` or `struct` for function or struct definition
//~^ ERROR missing `struct` for struct definition
}
fn main() {}

View File

@ -1,8 +1,13 @@
error: missing `fn` or `struct` for function or struct definition
error: missing `struct` for struct definition
--> $DIR/pub-ident-fn-3.rs:4:8
|
LL | pub bar();
| ---^--- help: if you meant to call a macro, try: `bar!`
| ^
|
help: add `struct` here to parse `bar` as a public struct
|
LL | pub struct bar();
| ++++++
error: aborting due to previous error

View File

@ -1,4 +1,4 @@
pub S();
//~^ ERROR missing `fn` or `struct` for function or struct definition
//~^ ERROR missing `struct` for struct definition
fn main() {}

View File

@ -1,8 +1,13 @@
error: missing `fn` or `struct` for function or struct definition
error: missing `struct` for struct definition
--> $DIR/pub-ident-fn-or-struct-2.rs:1:4
|
LL | pub S();
| ---^- help: if you meant to call a macro, try: `S!`
| ^
|
help: add `struct` here to parse `S` as a public struct
|
LL | pub struct S();
| ++++++
error: aborting due to previous error

View File

@ -0,0 +1,6 @@
// run-rustfix
pub struct T(String);
//~^ ERROR missing `struct` for struct definition
fn main() {}

View File

@ -0,0 +1,6 @@
// run-rustfix
pub T(String);
//~^ ERROR missing `struct` for struct definition
fn main() {}

View File

@ -0,0 +1,13 @@
error: missing `struct` for struct definition
--> $DIR/pub-ident-struct-4.rs:3:4
|
LL | pub T(String);
| ^
|
help: add `struct` here to parse `T` as a public struct
|
LL | pub struct T(String);
| ++++++
error: aborting due to previous error