-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
I-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Description
In case the loop
only contains a single match
statement, with either an empty block or a break
, while_let_loop
should IMO not be reported, since the code communicates a slightly different intention.
A loop
with a single, empty match
communicates, that driving the iterator/stream/generator/... to completion is the main focus, while a while
loop communicates, that the iterator/stream/generator/... is just a source of data and not the main focus.
loop {
match state.process_next() {
ControlFlow::Continue(_) => {},
ControlFlow::Break(_) => break,
}
}
while let ControlFlow::Continue(_) = state.process_next() {}
Small example: playground
Version
rustc 1.67.0-nightly (a00f8ba7f 2022-11-15)
binary: rustc
commit-hash: a00f8ba7fcac1b27341679c51bf5a3271fa82df3
commit-date: 2022-11-15
host: x86_64-unknown-linux-gnu
release: 1.67.0-nightly
LLVM version: 15.0.4
(also on stable)
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
I-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have