rust/src/test/ui/parser/recover-missing-semi.rs
Esteban Küber ac037c1359 Recover from missing semicolon based on the found token
When encountering one of a few keywords when a semicolon was
expected, suggest the semicolon and recover:

```
error: expected one of `.`, `;`, `?`, or an operator, found `let`
  --> $DIR/recover-missing-semi.rs:4:5
   |
LL |     let _: usize = ()
   |                      - help: missing semicolon here
LL |
LL |     let _ = 3;
   |     ^^^

error[E0308]: mismatched types
  --> $DIR/recover-missing-semi.rs:2:20
   |
LL |     let _: usize = ()
   |                    ^^ expected usize, found ()
   |
   = note: expected type `usize`
              found type `()`
```
2019-04-10 18:07:52 -07:00

14 lines
236 B
Rust

fn main() {
let _: usize = ()
//~^ ERROR mismatched types
let _ = 3;
//~^ ERROR expected one of
}
fn foo() -> usize {
let _: usize = ()
//~^ ERROR mismatched types
return 3;
//~^ ERROR expected one of
}