Skip to content

Conversation

@samueltardieu
Copy link
Member

@samueltardieu samueltardieu commented Jan 8, 2026

The iterator never loops when the closure used in, e.g., .any(), panics, not when it diverges as a regular return lets the iterator continue.

changelog: [never_loop]: do not consider return as preventing the iterator from looping

Fixes #16363

r? @Jarcho

The iterator never loops when the closure used in, e.g., `.any()`,
panics, not when it diverges as a regular `return` lets the iterator
continue.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 8, 2026
@samueltardieu
Copy link
Member Author

The bug was introduced in the current release cycle (1.94) and the lint is warn by default. It might be wise to either apply this PR when approved to the Rust repository before the next beta branch is cut.

Copy link
Contributor

@Jarcho Jarcho left a comment

Choose a reason for hiding this comment

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

@Jarcho Jarcho added this pull request to the merge queue Jan 8, 2026
@samueltardieu
Copy link
Member Author

@flip1995 Since the Rustup didn't get through yet, if you get a chance to include this PR which is being merged to Clippy right now, this is great.

As a side note, samueltardieu/rust@ce9462f can be applied on top of your current Rustup branch to make ./x test clippy pass (please re-read if you use it, I did it quite mechanically).

Merged via the queue into rust-lang:master with commit adade16 Jan 8, 2026
13 of 15 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 8, 2026
@flip1995
Copy link
Member

flip1995 commented Jan 9, 2026

Thanks for providing the fix. I redid the Clippy->Rust sync so this is included 🤝

@samueltardieu samueltardieu deleted the issues/16363 branch January 9, 2026 11:08
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

Successfully merging this pull request may close these issues.

Returning in iterator reduction closures triggers clippy::never_loop

4 participants