Skip to content

Conversation

bend-n
Copy link
Contributor

@bend-n bend-n commented Sep 18, 2025

now lints on

let mut x = [1,2,3].into_iter();
loop {
   let Some(x) = x.next() else { break };
   dbg!(x);
}
changelog: [`while_let_loop`]: extend to lint on `let else`

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Sep 18, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 18, 2025

r? @dswij

rustbot has assigned @dswij.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@samueltardieu
Copy link
Member

This should be auto-fixable, right?

@bend-n
Copy link
Contributor Author

bend-n commented Sep 18, 2025

in theory, yeah?

//~^ while_let_loop
let Some(_x) = y else { break };
}

Copy link
Member

@dswij dswij Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also include some test cases where the else block has side effects?

e.g.

    loop {
        //~^ while_let_loop
        let Some(_x) = y else {
            side_effect();
            break 
        };
    }

@dswij
Copy link
Member

dswij commented Sep 18, 2025

Should be auto-fixable. Let's do it in a separate PR. I created an issue for this #15702.

@bend-n would you want to help with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants