pub static DEREFERENCING_MUT_BINDING: &Lint
Expand description
The dereferencing_mut_binding
lint detects a mut x
pattern that resets the binding mode,
as this behavior will change in rust 2024.
§Example
let x = Some(123u32);
let _y = match &x {
Some(mut x) => {
x += 1;
x
}
None => 0,
};
{{produces}}
§Explanation
Without the mut
, x
would have type &u32
. Pre-2024, adding mut
makes x
have type
u32
, which was deemed surprising. After edition 2024, adding mut
will not change the
type of x
. This lint warns users of editions before 2024 to update their code.