Closed
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.