rust-lang / rust-lang/rust

Polymorphic recursion in async fn gives "queries overflow the depth limit" error

Open
#140,728 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-async-await A-diagnostics C-bug I-cycle T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
async fn recurse<T>() {
    recurse::<Option<T>>().await;
}
Current output
error: queries overflow the depth limit!
  |
  = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`playground`)
  = note: query depth increased by 130 when computing layout of `{async fn body of recurse<T>()}`
Desired output
Something that doesn't mention queries, and more prominently point me towards the recurse() function being the problem.
Rationale and extra context

No response

Other cases

Rust Version
Reproducible on the playground with version: 1.88.0-nightly (2025-05-06 27d6200a70601f6fcf41)
Anything else?

Discovered while experimenting with #140725

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 async recursion example in the Rust playground using the reported nightly version and compare the current query-overflow diagnostic with the requested wording. Then trace the compiler diagnostic path involved in computing the async function body's layout, using issue #140725 for related context; done means the error points clearly to recurse() without centering the message on queries.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.