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

Incorrect infinite loop detection in async functions #12338

Closed
AlexSherbinin opened this issue Feb 23, 2024 · 2 comments · Fixed by #13608
Closed

Incorrect infinite loop detection in async functions #12338

AlexSherbinin opened this issue Feb 23, 2024 · 2 comments · Fixed by #13608
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@AlexSherbinin
Copy link

AlexSherbinin commented Feb 23, 2024

Summary

When using clippy::infinite_loop lint with async function clippy emits not expected warning.

Lint Name

clippy::infinite_loop

Reproducer

I tried this code:

#![warn(clippy::infinite_loop)]

async fn foo() -> ! {
    loop {
    }
}

I saw this happen:

warning: infinite loop detected
 --> src/lib.rs:4:5
  |
4 | /     loop {
5 | |     }
  | |_____^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#infinite_loop
note: the lint level is defined here
 --> src/lib.rs:1:9
  |
1 | #![warn(clippy::infinite_loop)]
  |         ^^^^^^^^^^^^^^^^^^^^^
help: if this is intentional, consider specifing `!` as function return
  |
3 | async fn foo() -> !  -> !
  |                      ~~~~

I expected to see no lint

Version

rustc 1.75.0 (82e1608df 2023-12-21)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: x86_64-unknown-linux-gnu
release: 1.75.0
LLVM version: 17.0.6

Additional Labels

No response

@AlexSherbinin AlexSherbinin added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Feb 23, 2024
@CBSpeir
Copy link
Contributor

CBSpeir commented Feb 25, 2024

@rustbot claim

@CBSpeir CBSpeir removed their assignment Feb 29, 2024
@J-ZhengLi
Copy link
Member

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
3 participants