Skip to content

[[infinite_loop] fix infinite loop false positive #15157

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

Merged
merged 1 commit into from
Aug 9, 2025

Conversation

odysa
Copy link
Contributor

@odysa odysa commented Jun 27, 2025

changelog: [infinite_loop]: Improve handling of infinite loops in async blocks

Fix #14000

This PR refines the [infinite_loop] lint to avoid false positives when infinite loops occur inside async blocks that are not awaited (such as those that are spawned or assigned to variables for later use). The lint will now only trigger when the async block containing the loop is directly awaited.

@odysa odysa force-pushed the fix/inf-loop-err branch 4 times, most recently from c6af9da to 5e3812b Compare June 28, 2025 02:22
@odysa odysa changed the title fix infinite loop [[infinite_loop] fix infinite loop false positive Jul 12, 2025
@odysa odysa marked this pull request as ready for review July 12, 2025 15:18
@rustbot
Copy link
Collaborator

rustbot commented Jul 12, 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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 12, 2025
Copy link
Member

@samueltardieu samueltardieu left a comment

Choose a reason for hiding this comment

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

If it's not too late to do the change, I just noticed I had this unsent review pending in GitHub. Otherwise, I'll submit a cleanup PR.

@odysa
Copy link
Contributor Author

odysa commented Aug 6, 2025

LOL. It always gets me that comments are invisible until you finish the review.

@odysa odysa force-pushed the fix/inf-loop-err branch from 073054f to c945393 Compare August 8, 2025 02:17
@dswij
Copy link
Member

dswij commented Aug 9, 2025

Thanks @odysa @samueltardieu

@dswij dswij added this pull request to the merge queue Aug 9, 2025
@dswij dswij removed this pull request from the merge queue due to a manual request Aug 9, 2025
@dswij dswij added this pull request to the merge queue Aug 9, 2025
Merged via the queue into rust-lang:master with commit 386372a Aug 9, 2025
11 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Aug 9, 2025
}

fn await_async_block() {
// This SHOULD trigger the lint because the async block is awaited
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this was meant to be:

This should NOT trigger the lint because the async block is not awaited

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.

False positive for infinite_loop inside async block in function
5 participants