rust-lang / rust-lang/rust-clippy

async_yields_async with tokio: compile denied by clippy but rustc ok, probably not ICE but false positive

Open
#10,830 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

Summary
error: an async construct yields a type which is itself awaitable

let server_thread_handle = tokio::task::spawn(async move {
                loop {
                    /* doing something blocking */
                }
                ^ awaitable value not awaited
            });
| |_________- outer async construct
thread_handles.push(server_thread_handle);

   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#async_yields_async
   = note: `#[deny(clippy::async_yields_async)]` on by default
Version
rustc 1.70.0-beta.5 (16ec1c0a8 2023-05-20)
binary: rustc
commit-hash: 16ec1c0a8092cf54bc59d0ea9b10d8b50aed42be
commit-date: 2023-05-20
host: x86_64-unknown-linux-gnu
release: 1.70.0-beta.5
LLVM version: 16.0.2
Error output
Backtrace

<backtrace>
error: an async construct yields a type which is itself awaitable

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported async_yields_async diagnostic with tokio using rustc 1.70.0-beta.5, then compare Clippy's result with rustc's accepted behavior. Done means the report has a minimal reproducible example and the lint's behavior is corrected or clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.