Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement partial error recovery for
let
with BinOpEq
When parsing `let x: i8 += 1` the compiler interprets `i8` as a trait which makes it more complicated to do error recovery. More advanced error recovery is not implemented in this commit.
- Loading branch information
Showing
5 changed files
with
72 additions
and
2 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,7 @@ | ||
#![allow(bare_trait_objects)] | ||
|
||
fn main() { | ||
let a: i8 += 1; | ||
//~^ ERROR expected trait, found builtin type `i8` | ||
let _ = a; | ||
} |
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,9 @@ | ||
error[E0404]: expected trait, found builtin type `i8` | ||
--> $DIR/let-binop-plus.rs:4:12 | ||
| | ||
LL | let a: i8 += 1; | ||
| ^^ not a trait | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0404`. |
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,8 @@ | ||
fn main() { | ||
let a: i8 *= 1; //~ ERROR can't reassign to a uninitialized variable | ||
let _ = a; | ||
let b += 1; //~ ERROR can't reassign to a uninitialized variable | ||
let _ = b; | ||
let c *= 1; //~ ERROR can't reassign to a uninitialized variable | ||
let _ = c; | ||
} |
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,21 @@ | ||
error[E0067]: can't reassign to a uninitialized variable | ||
--> $DIR/let-binop.rs:2:15 | ||
| | ||
LL | let a: i8 *= 1; | ||
| ^^ help: replace with `=` to initialize the variable | ||
|
||
error[E0067]: can't reassign to a uninitialized variable | ||
--> $DIR/let-binop.rs:4:11 | ||
| | ||
LL | let b += 1; | ||
| ^^ help: replace with `=` to initialize the variable | ||
|
||
error[E0067]: can't reassign to a uninitialized variable | ||
--> $DIR/let-binop.rs:6:11 | ||
| | ||
LL | let c *= 1; | ||
| ^^ help: replace with `=` to initialize the variable | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0067`. |