rust-lang / rust-lang/rust

rustc fails to determine that async closure is `Send`, claims `&str` does not implement `Send`

Open
#154,523 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug needs-triage
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code:

pub fn issue() {
    must_be_send({
        async move {
            let mut arena = Arena;
            loop {
                let _res = call_loop(
                    "foobar",
                    async |_| {
                        arena.reset();
                        Ok(())
                    }
                ).await;
            }
        }
    });
}

fn must_be_send(_: impl Send) {}

async fn call_loop<'a>(
  did: &'a str,
  mut f: impl AsyncFnMut(&str) -> Result<(), ()>,
) -> Result<(), ()> {
    loop {
        f(did).await?;
    }
}

struct Arena;

impl Arena {
    fn reset(&mut self) {}
}

I expected to see this happen: Should compile.

Instead, this happened:

error: implementation of `Send` is not general enough
  --> src/lib.rs:2:5
   |
 2 | /     must_be_send({
 3 | |         async move {
 4 | |             let mut arena = Arena;
 5 | |             loop {
...  |
15 | |     });
   | |______^ implementation of `Send` is not general enough
   |
   = note: `Send` would have to be implemented for the type `&str`
   = note: ...but `Send` is actually implemented for the type `&'0 str`, for some specific lifetime `'0`

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

rustc --version --verbose:

1.94.1 (Playground)

rustc 1.96.0-nightly (20f19f461 2026-03-21) (Locally)

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-closure example in src/lib.rs with the reported stable and nightly rustc versions. Trace how rustc evaluates Send for the async closure and its borrowed &str lifetime. Done means the example compiles without the “implementation of Send is not general enough” error, with regression coverage for this case.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.