Skip to content

Send bound on RPITIT async method causes spurious lifetime errors #149407

@mincrmatt12

Description

@mincrmatt12

I tried this code (minimized from a larger case):

struct B;
struct C;

fn u(_c: &C, _b: &B) {}

trait T {
    fn a(&self, b: &B) -> impl Future<Output=()> + Send;
}

struct Timpl;

impl Timpl {
    async fn b<F>(&self, mut f: F)
    where
        F: AsyncFnMut(&mut C)
    {
        let mut c = C;
        f(&mut c).await;
        f(&mut c).await;
    }
}

impl T for Timpl {
    async fn a(&self, b: &B) {
        self.b(async |c| u(c, b)).await;
    }
}

I expect it to compile, instead an extremely vague 'lifetime error' is thrown out of rustc:

error[E0477]: the type `{async closure@src/lib.rs:25:16: 25:25}` does not fulfill the required lifetime
  --> src/lib.rs:24:5
   |
24 |     async fn a(&self, b: &B) {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0477`.

Removing the Send bound on T::a allows it to compile fine.

Meta

rustc --version --verbose:

rustc 1.93.0-nightly (1be6b13be 2025-11-26)
binary: rustc
commit-hash: 1be6b13be73dc12e98e51b403add4c41a0b77759
commit-date: 2025-11-26
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.5

playground link

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitC-bugCategory: This is a bug.T-typesRelevant to the types team, which will review and decide on the PR/issue.fixed-by-higher-ranked-assumptionsFixed by `-Zhigher-ranked-assumptions`

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions