Can't convert async closure to a function pointer
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Rust Playground reproduction and compare the async closure argument with the declared fn() -> F parameter. Investigate why the closure is rejected as a function pointer, then confirm the intended behavior with a focused compiler test; done means the reported example compiles with the expected future type or produces the correct, documented diagnostic.
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
- 45/100