Skip to content
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

Extend while_let_loop to warn even if there are statements after match #262

Closed
Zarathustra30 opened this issue Aug 30, 2015 · 1 comment · Fixed by #351
Closed

Extend while_let_loop to warn even if there are statements after match #262

Zarathustra30 opened this issue Aug 30, 2015 · 1 comment · Fixed by #351
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy T-AST Type: Requires working with the AST

Comments

@Zarathustra30
Copy link

The implementation of while_let_loop is incomplete. In cases when additional statements follow the match, such as the following:

loop {
    let bi = match bodies.next() {
        Some(bi) => bi,
        None => break
    };
    additional_statement1(bi);
    additional_statement2();
}

the loop can still be replaced with while let

while let Some(bi) = bodies.next() {
    additional_statement1(bi);
    additional_statement2();
}

These snippets are slightly different in theory, but identical in practice.

@llogiq
Copy link
Contributor

llogiq commented Aug 30, 2015

Good catch!

@Manishearth Manishearth added good-first-issue These issues are a good way to get started with Clippy C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages T-AST Type: Requires working with the AST labels Aug 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy T-AST Type: Requires working with the AST
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants