-
Couldn't load subscription status.
- Fork 13.9k
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
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."
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.