Skip to content

while_let_loop should not be reported for empty match statements #10037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Tracked by #12046
DzenanJupic opened this issue Dec 6, 2022 · 2 comments
Open
Tracked by #12046

while_let_loop should not be reported for empty match statements #10037

DzenanJupic opened this issue Dec 6, 2022 · 2 comments

Comments

@DzenanJupic
Copy link

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

@PartiallyUntyped
Copy link
Contributor

@rustbot label +False-positive

@rustbot
Copy link
Collaborator

rustbot commented Dec 29, 2023

Error: Label False-positive can only be set by Rust team members

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants