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
8 changed files with 42 additions and 7 deletions
|
@ -412,7 +412,7 @@ impl<'a> Parser<'a> {
|
||||||
} else if self.check(&token::OpenDelim(Delimiter::Brace)) {
|
} else if self.check(&token::OpenDelim(Delimiter::Brace)) {
|
||||||
self.bump(); // `{`
|
self.bump(); // `{`
|
||||||
("fn", kw_name, false)
|
("fn", kw_name, false)
|
||||||
} else if self.check(&token::Colon) {
|
} else if self.check(&token::Semi) {
|
||||||
let kw = "struct";
|
let kw = "struct";
|
||||||
(kw, kw, false)
|
(kw, kw, false)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
mod foo {
|
mod foo {
|
||||||
pub bar();
|
pub bar();
|
||||||
//~^ ERROR missing `fn` or `struct` for function or struct definition
|
//~^ ERROR missing `struct` for struct definition
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
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
|
--> $DIR/pub-ident-fn-3.rs:4:8
|
||||||
|
|
|
|
||||||
LL | pub bar();
|
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
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
pub S();
|
pub S();
|
||||||
//~^ ERROR missing `fn` or `struct` for function or struct definition
|
//~^ ERROR missing `struct` for struct definition
|
||||||
|
|
||||||
fn main() {}
|
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
|
--> $DIR/pub-ident-fn-or-struct-2.rs:1:4
|
||||||
|
|
|
|
||||||
LL | pub S();
|
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
|
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…
Add table
Add a link
Reference in a new issue