Closed
Description
This program:
fn foo(_x: u32) {
_x = 4;
}
fn main() {}
produces this error:
error[E0384]: re-assignment of immutable variable `_x`
--> src/main.rs:2:5
|
1 | fn foo(_x: u32) {
| -- first assignment to `_x`
2 | _x = 4;
| ^^^^^^ re-assignment of immutable variable
I consider this a somewhat confusing error. I think it should rather be:
error[E0384]: assignment of immutable argument `_x`
--> src/main.rs:2:5
|
1 | fn foo(_x: u32) {
| -- `_x` not declared as `mut`
2 | _x = 4;
| ^^^^^^ assignment of immutable argument `_x`
perhaps with a suggestion or something.
This error is issued by the borrow checker, so to do this right we should also modify the MIR-based borrow checker.