Closed
Description
One can make a mistake where they mistype =
to ==
.
Consider the following code:
fn main() {
let mut a = 10;
println!("A is {}", a);
if 1 == 2 {
a = 20;
} else {
a == 30; // Oops, meant assignment
}
println!("A is now {}", a); // Still 10
}
No warning is produced for this code.
I'd argue that this is a common enough mistake to justify warning by default for it.
If the user explicitly wants to do this operation for side effects or whatever, they can do let _ = a == b;
, similarly to the explicit version for #[must_use]
types.
Metadata
Metadata
Assignees
Labels
No labels