1
Fork 0

Auto merge of #127419 - trevyn:issue-125446, r=fee1-dead

Add suggestions for possible missing `fn`, `struct`, or `enum` keywords

Closes #125446
Closes #65381
This commit is contained in:
bors 2024-07-10 18:27:32 +00:00
commit 0c81f94b9a
42 changed files with 308 additions and 146 deletions

View file

@ -1,5 +1,7 @@
extern "C" {
f(); //~ ERROR expected one of `!` or `::`, found `(`
f();
//~^ ERROR missing `fn` or `struct` for function or struct definition
//~| HELP if you meant to call a macro, try
}
fn main() {

View file

@ -1,12 +1,18 @@
error: expected one of `!` or `::`, found `(`
--> $DIR/extern-no-fn.rs:2:6
error: missing `fn` or `struct` for function or struct definition
--> $DIR/extern-no-fn.rs:2:5
|
LL | extern "C" {
| - while parsing this item list starting here
LL | f();
| ^ expected one of `!` or `::`
| ^
...
LL | }
| - the item list ends here
|
help: if you meant to call a macro, try
|
LL | f!();
| ~~
error: aborting due to 1 previous error

View file

@ -0,0 +1,6 @@
Whoops {
//~^ ERROR missing `enum` for enum definition
//~| HELP add `enum` here to parse `Whoops` as an enum
OptionA,
OptionB,
}

View file

@ -0,0 +1,13 @@
error: missing `enum` for enum definition
--> $DIR/missing-enum-issue-125446.rs:1:1
|
LL | Whoops {
| ^^^^^^
|
help: add `enum` here to parse `Whoops` as an enum
|
LL | enum Whoops {
| ++++
error: aborting due to 1 previous error

View file

@ -0,0 +1,2 @@
Whoops {}
//~^ ERROR missing `enum` or `struct` for enum or struct definition

View file

@ -0,0 +1,8 @@
error: missing `enum` or `struct` for enum or struct definition
--> $DIR/missing-enum-or-struct-issue-125446.rs:1:1
|
LL | Whoops {}
| ^^^^^^
error: aborting due to 1 previous error

View file

@ -0,0 +1,7 @@
whoops() {}
//~^ ERROR missing `fn` for function definition
//~| HELP add `fn` here to parse `whoops` as a function
fn main() {
whoops();
}

View file

@ -0,0 +1,13 @@
error: missing `fn` for function definition
--> $DIR/missing-fn-issue-125446.rs:1:1
|
LL | whoops() {}
| ^^^^^^
|
help: add `fn` here to parse `whoops` as a function
|
LL | fn whoops() {}
| ++
error: aborting due to 1 previous error

View file

@ -0,0 +1,4 @@
main() {
//~^ ERROR missing `fn` for function definition
//~| HELP add `fn` here to parse `main` as a function
}

View file

@ -0,0 +1,13 @@
error: missing `fn` for function definition
--> $DIR/missing-fn-issue-65381-1.rs:1:1
|
LL | main() {
| ^^^^
|
help: add `fn` here to parse `main` as a function
|
LL | fn main() {
| ++
error: aborting due to 1 previous error

View file

@ -0,0 +1,3 @@
main();
//~^ ERROR missing `fn` or `struct` for function or struct definition
//~| HELP if you meant to call a macro, try

View file

@ -0,0 +1,13 @@
error: missing `fn` or `struct` for function or struct definition
--> $DIR/missing-fn-issue-65381-2.rs:1:1
|
LL | main();
| ^^^^
|
help: if you meant to call a macro, try
|
LL | main!();
| ~~~~~
error: aborting due to 1 previous error

View file

@ -0,0 +1,4 @@
pub const initial_value() -> Self {
//~^ ERROR missing `fn` for function definition
//~| HELP add `fn` here to parse `initial_value` as a function
}

View file

@ -0,0 +1,13 @@
error: missing `fn` for function definition
--> $DIR/missing-fn-issue-65381-3.rs:1:11
|
LL | pub const initial_value() -> Self {
| ^^^^^^^^^^^^^
|
help: add `fn` here to parse `initial_value` as a function
|
LL | pub const fn initial_value() -> Self {
| ++
error: aborting due to 1 previous error

View file

@ -0,0 +1,5 @@
Whoops {
//~^ ERROR missing `struct` for struct definition
//~| HELP add `struct` here to parse `Whoops` as a struct
value: u64,
}

View file

@ -0,0 +1,13 @@
error: missing `struct` for struct definition
--> $DIR/missing-struct-issue-125446.rs:1:1
|
LL | Whoops {
| ^^^^^^
|
help: add `struct` here to parse `Whoops` as a struct
|
LL | struct Whoops {
| ++++++
error: aborting due to 1 previous error