-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Given the code
rust/src/test/ui/parser/recover-from-bad-variant.rs
Lines 1 to 14 in 3592079
enum Enum { | |
Foo { a: usize, b: usize }, | |
Bar(usize, usize), | |
} | |
fn main() { | |
let x = Enum::Foo(a: 3, b: 4); | |
//~^ ERROR expected type, found `3` | |
match x { | |
Enum::Foo(a, b) => {} | |
//~^ ERROR expected tuple struct/variant, found struct variant `Enum::Foo` | |
Enum::Bar(a, b) => {} | |
} | |
} |
we emit
rust/src/test/ui/parser/recover-from-bad-variant.stderr
Lines 1 to 21 in 3592079
error: expected type, found `3` | |
--> $DIR/recover-from-bad-variant.rs:7:26 | |
| | |
LL | let x = Enum::Foo(a: 3, b: 4); | |
| ^ expecting a type here because of type ascription | |
| | |
= note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `<expr>: <type>` | |
note: this expression expects an ascribed type after the colon | |
--> $DIR/recover-from-bad-variant.rs:7:23 | |
| | |
LL | let x = Enum::Foo(a: 3, b: 4); | |
| ^ | |
= help: this might be indicative of a syntax error elsewhere | |
error[E0532]: expected tuple struct/variant, found struct variant `Enum::Foo` | |
--> $DIR/recover-from-bad-variant.rs:10:9 | |
| | |
LL | Enum::Foo(a, b) => {} | |
| ^^^^^^^^^ did you mean `Enum::Foo { /* fields */ }`? | |
error: aborting due to 2 previous errors |
We should emit something closer to
error: expected type, found `3`
--> $DIR/recover-from-bad-variant.rs:7:26
|
LL | let x = Enum::Foo(a: 3, b: 4);
| ^ expecting a type here because of type ascription
error[E0532]: expected tuple struct/variant, found struct variant `Enum::Foo`
--> $DIR/recover-from-bad-variant.rs:10:9
|
LL | Enum::Foo(a, b) => {}
| ^^^^^^^^^ did you mean `Enum::Foo { a, b }`?
error: aborting due to 2 previous errors
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.