Code
fn change_val(mut val: &mut i32) {
val = &mut 10;
}
Current output
warning: value assigned to `val` is never read
--> src/lib.rs:2:5
|
2 | val = &mut 10;
| ^^^
|
= note: `#[warn(unused_assignments)]` on by default
help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding
|
1 ~ fn change_val(val: &mut mut i32) {
2 ~ *val = 10;
|
<other warning and error elided as they do not matter here>
Desired output
warning: value assigned to `val` is never read
--> src/lib.rs:2:5
|
2 | val = &mut 10;
| ^^^
|
= note: `#[warn(unused_assignments)]` on by default
help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding
|
1 ~ fn change_val(val: &mut i32) {
2 ~ *val = 10;
|
<other warning and error elided as they do not matter here>
Rationale and extra context
This hint was added in #134977. Encountered this while looking at #136026.
cc @estebank as you added this suggestion
Other cases
Rust Version
1.86.0-nightly (2025-01-23 99768c80a1c094a5cfc3)
Anything else?
No response
Code
Current output
Desired output
Rationale and extra context
This hint was added in #134977. Encountered this while looking at #136026.
cc @estebank as you added this suggestion
Other cases
Rust Version
Anything else?
No response