-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-type-systemArea: Type systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.T-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.
Description
An example:
struct A;
fn bar(x: &mut A) {}
fn foo(x: &mut A) {
bar(&mut x);
}
results in:
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
--> src/lib.rs:6:9
|
5 | fn foo(x: &mut A) {
| - help: consider changing this to be mutable: `mut x`
6 | bar(&mut x);
| ^^^^^^ cannot borrow as mutable
but we could say:
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
--> src/lib.rs:6:9
|
5 | fn foo(x: &mut A) {
6 | bar(&mut x);
| ^^^^^^ cannot borrow as mutable
| ---- help: remove the unnecessary `&mut` here
Metadata
Metadata
Assignees
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-type-systemArea: Type systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.T-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.