Skip to content

Clippy error this loop never actually loops when use loop with select! #12834

@veerapatyok

Description

@veerapatyok

Description

clippy version
clippy 0.1.78 (9b00956 2024-04-29)

I made signal for daemon service for graceful shutdown but I got error from clippy when I use loop with select!
example code

let local_worker = LocalSet::new();
local_worker
.run_until(async {
	loop {
		tokio::select! {
			Ok(_) = sig_rx.recv() => {
				tracing::info!("Shutdown signal received.");
				break;
			},
		}
	}
})
.await;

error

error: this loop never actually loops
  --> api_log_svc/src/app.rs:41:4
   |
41 | /             loop {
42 | |                 tokio::select! {
43 | |                     Ok(_) = sig_rx.recv() => {
44 | |                         tracing::info!("Shutdown signal received.");
...  |
74 | |                 }
75 | |             }
   | |_____________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#never_loop
   = note: `#[deny(clippy::never_loop)]` on by default

error: could not compile `api_log_svc` (lib) due to 1 previous error

In the past I never got this error before and How to fix it?

Version

rustc 1.78.0 (9b00956e5 2024-04-29)
binary: rustc
commit-hash: 9b00956e56009bab2aa15d7bff10916599e3d6d6
commit-date: 2024-04-29
host: x86_64-unknown-linux-gnu
release: 1.78.0
LLVM version: 18.1.2

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions