- Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
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 AST
Description
The following code should gracefully recover from parse error, provide an appropriate suggestion and continue to typechk:
enum Foo { Bar { } /// doc Qux { } Quz, } fn main() { let x: usize = Foo::Quz; } error: expected one of `,` or `}`, found `/// doc` --> src/lib.rs:4:5 | 3 | } | - help: missing comma here 4 | /// doc | ^^^^^^^ unexpected token error: expected one of `,` or `}`, found `Quz` --> src/lib.rs:7:5 | 6 | } | - help: missing comma here 7 | Quz, | ^^^ unexpected token error[E0308]: mismatched types --> src/main.rs:10:20 | 10 | let x: usize = Foo::Quz; | ^^^^^^^^ expected usize, found enum `Foo` | = note: expected type `usize` found type `Foo` If this could be generalized to all "unexpected token" cases, even better, but that might get tricky.
CC #48724.
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 AST