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:
commit
0c81f94b9a
42 changed files with 308 additions and 146 deletions
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
6
tests/ui/parser/missing-enum-issue-125446.rs
Normal file
6
tests/ui/parser/missing-enum-issue-125446.rs
Normal file
|
@ -0,0 +1,6 @@
|
|||
Whoops {
|
||||
//~^ ERROR missing `enum` for enum definition
|
||||
//~| HELP add `enum` here to parse `Whoops` as an enum
|
||||
OptionA,
|
||||
OptionB,
|
||||
}
|
13
tests/ui/parser/missing-enum-issue-125446.stderr
Normal file
13
tests/ui/parser/missing-enum-issue-125446.stderr
Normal 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
|
||||
|
2
tests/ui/parser/missing-enum-or-struct-issue-125446.rs
Normal file
2
tests/ui/parser/missing-enum-or-struct-issue-125446.rs
Normal file
|
@ -0,0 +1,2 @@
|
|||
Whoops {}
|
||||
//~^ ERROR missing `enum` or `struct` for enum or struct definition
|
|
@ -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
|
||||
|
7
tests/ui/parser/missing-fn-issue-125446.rs
Normal file
7
tests/ui/parser/missing-fn-issue-125446.rs
Normal 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();
|
||||
}
|
13
tests/ui/parser/missing-fn-issue-125446.stderr
Normal file
13
tests/ui/parser/missing-fn-issue-125446.stderr
Normal 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
|
||||
|
4
tests/ui/parser/missing-fn-issue-65381-1.rs
Normal file
4
tests/ui/parser/missing-fn-issue-65381-1.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
main() {
|
||||
//~^ ERROR missing `fn` for function definition
|
||||
//~| HELP add `fn` here to parse `main` as a function
|
||||
}
|
13
tests/ui/parser/missing-fn-issue-65381-1.stderr
Normal file
13
tests/ui/parser/missing-fn-issue-65381-1.stderr
Normal 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
|
||||
|
3
tests/ui/parser/missing-fn-issue-65381-2.rs
Normal file
3
tests/ui/parser/missing-fn-issue-65381-2.rs
Normal 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
|
13
tests/ui/parser/missing-fn-issue-65381-2.stderr
Normal file
13
tests/ui/parser/missing-fn-issue-65381-2.stderr
Normal 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
|
||||
|
4
tests/ui/parser/missing-fn-issue-65381-3.rs
Normal file
4
tests/ui/parser/missing-fn-issue-65381-3.rs
Normal 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
|
||||
}
|
13
tests/ui/parser/missing-fn-issue-65381-3.stderr
Normal file
13
tests/ui/parser/missing-fn-issue-65381-3.stderr
Normal 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
|
||||
|
5
tests/ui/parser/missing-struct-issue-125446.rs
Normal file
5
tests/ui/parser/missing-struct-issue-125446.rs
Normal file
|
@ -0,0 +1,5 @@
|
|||
Whoops {
|
||||
//~^ ERROR missing `struct` for struct definition
|
||||
//~| HELP add `struct` here to parse `Whoops` as a struct
|
||||
value: u64,
|
||||
}
|
13
tests/ui/parser/missing-struct-issue-125446.stderr
Normal file
13
tests/ui/parser/missing-struct-issue-125446.stderr
Normal 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
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue