unused_assignments does not care about unused assignments to reference derefs

e764dc4
Opened by Oli Scherer at 2023-09-24 16:58:22
pub fn foo(b: bool, x: &mut i32) {
    if b {
        *x = 6;
    }
    *x = 7;
}

does not emit the unused_assignments lint. I understand that this is not possible for DerefMut in general, because every call to deref_mut (via desugaring *) can result in a different reference, but for pure references everything should be good.

A case of not linting this causing a bug was found in rustc: https://github.com/rust-lang/rust/blob/2f1ef9ef1181298d46e79d5dde6bafeb6483926f/src/librustc_mir/transform/inline.rs#L614-L620