-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.WG-diagnosticsWorking group: DiagnosticsWorking group: Diagnostics
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.
leonardo-m and estebank
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.WG-diagnosticsWorking group: DiagnosticsWorking group: Diagnostics