forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#59866 - estebank:recover-missing-semi, r=pe…
…trochenkov 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 `()` ```
- Loading branch information
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
error: expected one of `.`, `;`, `?`, or an operator, found `let` | ||
--> $DIR/recover-missing-semi.rs:4:5 | ||
| | ||
LL | let _: usize = () | ||
| - help: a semicolon may be missing here | ||
LL | | ||
LL | let _ = 3; | ||
| ^^^ | ||
|
||
error: expected one of `.`, `;`, `?`, or an operator, found `return` | ||
--> $DIR/recover-missing-semi.rs:11:5 | ||
| | ||
LL | let _: usize = () | ||
| - help: a semicolon may be missing here | ||
LL | | ||
LL | return 3; | ||
| ^^^^^^ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/recover-missing-semi.rs:2:20 | ||
| | ||
LL | let _: usize = () | ||
| ^^ expected usize, found () | ||
| | ||
= note: expected type `usize` | ||
found type `()` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/recover-missing-semi.rs:9:20 | ||
| | ||
LL | let _: usize = () | ||
| ^^ expected usize, found () | ||
| | ||
= note: expected type `usize` | ||
found type `()` | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |