Skip to content

Can't convert async closure to a function pointer #149339

@programmerjake

Description

@programmerjake

I tried this code:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=d54c26bc3a2ed018b18251d24faf4cce

pub fn f<F>(_f: fn() -> F) {}

pub fn g() {
    f(async || {});
}

I expected to see this happen: successfully compile with F being the future type returned by the async closure.

Instead, this happened:

error[E0308]: mismatched types
 --> src/lib.rs:4:7
  |
4 |     f(async || {});
  |     - ^^^^^^^^^^^ expected fn pointer, found `{async closure@lib.rs:4:7}`
  |     |
  |     arguments to this function are incorrect
  |
  = note: expected fn pointer `fn() -> _`
                found closure `{async closure@src/lib.rs:4:7: 4:15}`

Meta

rustc --version --verbose:

1.93.0-nightly

(2025-11-24 c871d09d1cc32a649f4c)

@rustbot label +A-async-closures

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-closures`async || {}`C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions