Closed
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
Area: The borrow checkerArea: Messages for errors, warnings, and lintsArea: Type systemCategory: An issue proposing an enhancement or a PR with one.Diagnostics: A diagnostic that is giving misleading or incorrect information.Relevant to the compiler team, which will review and decide on the PR/issue.