diff options
| author | bors <bors@rust-lang.org> | 2024-07-10 18:27:32 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-07-10 18:27:32 +0000 |
| commit | 0c81f94b9a6207fb1fc080caa83584dea2d71fc6 (patch) | |
| tree | 424fbe9a52a1c0398b127471cacdb0857423c3cf /tests/ui/parser | |
| parent | c092b289764530221d09e000a789222bddb2c53c (diff) | |
| parent | b40adc9d3b56f230f295011ff78b0dfd378683ef (diff) | |
Auto merge of #127419 - trevyn:issue-125446, r=fee1-dead
Add suggestions for possible missing `fn`, `struct`, or `enum` keywords Closes #125446 Closes #65381
Diffstat (limited to 'tests/ui/parser')
| -rw-r--r-- | tests/ui/parser/extern-no-fn.rs | 4 | ||||
| -rw-r--r-- | tests/ui/parser/extern-no-fn.stderr | 12 | ||||
| -rw-r--r-- | tests/ui/parser/missing-enum-issue-125446.rs | 6 | ||||
| -rw-r--r-- | tests/ui/parser/missing-enum-issue-125446.stderr | 13 | ||||
| -rw-r--r-- | tests/ui/parser/missing-enum-or-struct-issue-125446.rs | 2 | ||||
| -rw-r--r-- | tests/ui/parser/missing-enum-or-struct-issue-125446.stderr | 8 | ||||
| -rw-r--r-- | tests/ui/parser/missing-fn-issue-125446.rs | 7 | ||||
| -rw-r--r-- | tests/ui/parser/missing-fn-issue-125446.stderr | 13 | ||||
| -rw-r--r-- | tests/ui/parser/missing-fn-issue-65381-1.rs | 4 | ||||
| -rw-r--r-- | tests/ui/parser/missing-fn-issue-65381-1.stderr | 13 | ||||
| -rw-r--r-- | tests/ui/parser/missing-fn-issue-65381-2.rs | 3 | ||||
| -rw-r--r-- | tests/ui/parser/missing-fn-issue-65381-2.stderr | 13 | ||||
| -rw-r--r-- | tests/ui/parser/missing-fn-issue-65381-3.rs | 4 | ||||
| -rw-r--r-- | tests/ui/parser/missing-fn-issue-65381-3.stderr | 13 | ||||
| -rw-r--r-- | tests/ui/parser/missing-struct-issue-125446.rs | 5 | ||||
| -rw-r--r-- | tests/ui/parser/missing-struct-issue-125446.stderr | 13 |
16 files changed, 129 insertions, 4 deletions
diff --git a/tests/ui/parser/extern-no-fn.rs b/tests/ui/parser/extern-no-fn.rs index 73568609cdf..e965b390f07 100644 --- a/tests/ui/parser/extern-no-fn.rs +++ b/tests/ui/parser/extern-no-fn.rs @@ -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() { diff --git a/tests/ui/parser/extern-no-fn.stderr b/tests/ui/parser/extern-no-fn.stderr index 2e434afb218..03826e4a93b 100644 --- a/tests/ui/parser/extern-no-fn.stderr +++ b/tests/ui/parser/extern-no-fn.stderr @@ -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 diff --git a/tests/ui/parser/missing-enum-issue-125446.rs b/tests/ui/parser/missing-enum-issue-125446.rs new file mode 100644 index 00000000000..8d2cdb0dc40 --- /dev/null +++ b/tests/ui/parser/missing-enum-issue-125446.rs @@ -0,0 +1,6 @@ +Whoops { +//~^ ERROR missing `enum` for enum definition +//~| HELP add `enum` here to parse `Whoops` as an enum + OptionA, + OptionB, +} diff --git a/tests/ui/parser/missing-enum-issue-125446.stderr b/tests/ui/parser/missing-enum-issue-125446.stderr new file mode 100644 index 00000000000..113b147473c --- /dev/null +++ b/tests/ui/parser/missing-enum-issue-125446.stderr @@ -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 + diff --git a/tests/ui/parser/missing-enum-or-struct-issue-125446.rs b/tests/ui/parser/missing-enum-or-struct-issue-125446.rs new file mode 100644 index 00000000000..c817ffaf859 --- /dev/null +++ b/tests/ui/parser/missing-enum-or-struct-issue-125446.rs @@ -0,0 +1,2 @@ +Whoops {} +//~^ ERROR missing `enum` or `struct` for enum or struct definition diff --git a/tests/ui/parser/missing-enum-or-struct-issue-125446.stderr b/tests/ui/parser/missing-enum-or-struct-issue-125446.stderr new file mode 100644 index 00000000000..15916cebf45 --- /dev/null +++ b/tests/ui/parser/missing-enum-or-struct-issue-125446.stderr @@ -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 + diff --git a/tests/ui/parser/missing-fn-issue-125446.rs b/tests/ui/parser/missing-fn-issue-125446.rs new file mode 100644 index 00000000000..73c9c3a60e1 --- /dev/null +++ b/tests/ui/parser/missing-fn-issue-125446.rs @@ -0,0 +1,7 @@ +whoops() {} +//~^ ERROR missing `fn` for function definition +//~| HELP add `fn` here to parse `whoops` as a function + +fn main() { + whoops(); +} diff --git a/tests/ui/parser/missing-fn-issue-125446.stderr b/tests/ui/parser/missing-fn-issue-125446.stderr new file mode 100644 index 00000000000..2a92e0062cb --- /dev/null +++ b/tests/ui/parser/missing-fn-issue-125446.stderr @@ -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 + diff --git a/tests/ui/parser/missing-fn-issue-65381-1.rs b/tests/ui/parser/missing-fn-issue-65381-1.rs new file mode 100644 index 00000000000..ac0299ae37b --- /dev/null +++ b/tests/ui/parser/missing-fn-issue-65381-1.rs @@ -0,0 +1,4 @@ +main() { +//~^ ERROR missing `fn` for function definition +//~| HELP add `fn` here to parse `main` as a function +} diff --git a/tests/ui/parser/missing-fn-issue-65381-1.stderr b/tests/ui/parser/missing-fn-issue-65381-1.stderr new file mode 100644 index 00000000000..95ccd8518ee --- /dev/null +++ b/tests/ui/parser/missing-fn-issue-65381-1.stderr @@ -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 + diff --git a/tests/ui/parser/missing-fn-issue-65381-2.rs b/tests/ui/parser/missing-fn-issue-65381-2.rs new file mode 100644 index 00000000000..e8c214a58b6 --- /dev/null +++ b/tests/ui/parser/missing-fn-issue-65381-2.rs @@ -0,0 +1,3 @@ +main(); +//~^ ERROR missing `fn` or `struct` for function or struct definition +//~| HELP if you meant to call a macro, try diff --git a/tests/ui/parser/missing-fn-issue-65381-2.stderr b/tests/ui/parser/missing-fn-issue-65381-2.stderr new file mode 100644 index 00000000000..e13d395d70d --- /dev/null +++ b/tests/ui/parser/missing-fn-issue-65381-2.stderr @@ -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 + diff --git a/tests/ui/parser/missing-fn-issue-65381-3.rs b/tests/ui/parser/missing-fn-issue-65381-3.rs new file mode 100644 index 00000000000..28e5b5aa430 --- /dev/null +++ b/tests/ui/parser/missing-fn-issue-65381-3.rs @@ -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 +} diff --git a/tests/ui/parser/missing-fn-issue-65381-3.stderr b/tests/ui/parser/missing-fn-issue-65381-3.stderr new file mode 100644 index 00000000000..883295baede --- /dev/null +++ b/tests/ui/parser/missing-fn-issue-65381-3.stderr @@ -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 + diff --git a/tests/ui/parser/missing-struct-issue-125446.rs b/tests/ui/parser/missing-struct-issue-125446.rs new file mode 100644 index 00000000000..439087aeec9 --- /dev/null +++ b/tests/ui/parser/missing-struct-issue-125446.rs @@ -0,0 +1,5 @@ +Whoops { +//~^ ERROR missing `struct` for struct definition +//~| HELP add `struct` here to parse `Whoops` as a struct + value: u64, +} diff --git a/tests/ui/parser/missing-struct-issue-125446.stderr b/tests/ui/parser/missing-struct-issue-125446.stderr new file mode 100644 index 00000000000..ff3135b2357 --- /dev/null +++ b/tests/ui/parser/missing-struct-issue-125446.stderr @@ -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 + |
