-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)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-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
Description
Not quite sure how to name this issue, please change the title to something more accurate!
Recently ran into this issue:
fn main() {
let b = false; // dangerous semi-colon
|| true;
println!("{}", b);
}
The boolean statement was long, so I broke it out onto a new line. However, I accidentally added the annotated semi-colon. The || true
line is interpreted as an anonymous closure statement (no let binding, not even a callable closure) as opposed to a boolean OR.
When executing this code, it yields false
. Luckily, someone caught the issue in code review, but a compiler warning noting the unused closure would have been really helpful!
tomusdrw, insipx, aDotInTheVoid, yvt and sivizius
Metadata
Metadata
Assignees
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)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-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.