-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
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:
rust/src/librustc_mir/transform/inline.rs
Lines 614 to 620 in 2f1ef9e
if idx < self.args.len() { | |
match self.args[idx] { | |
Operand::Consume(Lvalue::Local(l)) => *local = l, | |
ref op => bug!("Arg operand `{:?}` is {:?}, not local", idx, op) | |
} | |
} | |
*local = self.local_map[Local::new(idx - self.args.len())]; |
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.