forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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#71976 - mibac138:let-recovery, r=estebank
Improve diagnostics for `let x += 1` Fixes(?) rust-lang#66736 The code responsible for the `E0404` errors is [here](https://github.com/rust-lang/rust/blob/master/src/librustc_parse/parser/ty.rs#L399-L424) which I don't think can be easily modified to prevent emitting an error in one specific case. Because of this I couldn't get rid of `E0404` and instead added `E0067` along with a help message which will fix the problem. r? @estebank
- Loading branch information
Showing
3 changed files
with
50 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,8 @@ | ||
fn main() { | ||
let a: i8 *= 1; //~ ERROR can't reassign to an uninitialized variable | ||
let _ = a; | ||
let b += 1; //~ ERROR can't reassign to an uninitialized variable | ||
let _ = b; | ||
let c *= 1; //~ ERROR can't reassign to an 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,20 @@ | ||
error: can't reassign to an uninitialized variable | ||
--> $DIR/let-binop.rs:2:15 | ||
| | ||
LL | let a: i8 *= 1; | ||
| ^^ help: initialize the variable | ||
|
||
error: can't reassign to an uninitialized variable | ||
--> $DIR/let-binop.rs:4:11 | ||
| | ||
LL | let b += 1; | ||
| ^^ help: initialize the variable | ||
|
||
error: can't reassign to an uninitialized variable | ||
--> $DIR/let-binop.rs:6:11 | ||
| | ||
LL | let c *= 1; | ||
| ^^ help: initialize the variable | ||
|
||
error: aborting due to 3 previous errors | ||
|