Closed
Description
Code
I tried this code:
pub struct Foo(i32);
pub fn foo(mut x: &mut Foo) {
x.0 = 1;
}
I expected to see this: The compiler should tell me to remove the mut
, since it isn't necessary:
warning: variable does not need to be mutable
--> src/lib.rs:3:12
|
3 | pub fn foo(mut x: &mut Foo) {
| ----^
| |
| help: remove this `mut`
|
= note: `#[warn(unused_mut)]` on by default
Instead this happened: The code compiles without a lint.
The lint triggers correctly with an explicit reborrow: (&mut *x).0 = 1;
Meta
playground 1.71.0-nightly (2023-04-25 458d4da)
@rustbot label A-diagnostics A-lint