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:
parent
a84adba552
commit
0757d5f83f
@ -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 {
|
||||
|
@ -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() {}
|
||||
|
@ -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
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
pub S();
|
||||
//~^ ERROR missing `fn` or `struct` for function or struct definition
|
||||
//~^ ERROR missing `struct` for struct definition
|
||||
|
||||
fn main() {}
|
||||
|
@ -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
|
||||
|
||||
|
6
tests/ui/pub/pub-ident-struct-4.fixed
Normal file
6
tests/ui/pub/pub-ident-struct-4.fixed
Normal file
@ -0,0 +1,6 @@
|
||||
// run-rustfix
|
||||
|
||||
pub struct T(String);
|
||||
//~^ ERROR missing `struct` for struct definition
|
||||
|
||||
fn main() {}
|
6
tests/ui/pub/pub-ident-struct-4.rs
Normal file
6
tests/ui/pub/pub-ident-struct-4.rs
Normal file
@ -0,0 +1,6 @@
|
||||
// run-rustfix
|
||||
|
||||
pub T(String);
|
||||
//~^ ERROR missing `struct` for struct definition
|
||||
|
||||
fn main() {}
|
13
tests/ui/pub/pub-ident-struct-4.stderr
Normal file
13
tests/ui/pub/pub-ident-struct-4.stderr
Normal 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user