-
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 lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.
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
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.