Closed
Description
Take a look at this logically wrong example:
fn main() {
let mut x = 1;
let y = (1..10).fold(0, move|acc, e| {
x *= e; // should warn: new value of `x` never read
acc + e
});
println!("{} {}", x, y); // outputs: `1 45`
}
It would be best if the compiler points out that "updating x
inside the closure will not have an external effect." Though, I would be happy if the compiler at least pointed out that "the modified value in the new binding x
is never read."