-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Open
Labels
A-async-closures`async || {}``async || {}`C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
Metadata
Metadata
Assignees
Labels
A-async-closures`async || {}``async || {}`C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.