Repository navigation
Tracking Issue for #![feature(async_fn_traits)] #146790
Copy link
Copy link
Open
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-needs-summaryStatus: It's hard to tell what's been done and what hasn't! Someone should do some investigation.Status: It's hard to tell what's been done and what hasn't! Someone should do some investigation.T-langRelevant to the language teamRelevant to the language teamT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Description
Feature gate: #![feature(async_fn_traits)]
RFC: I couldn't find one.
Public API
This is a tracking issue for the methods and associated types of the AsyncFn family of traits:
The traits themselves are stable, but it is not possible to implement them or (critically) write bounds on the returned future on stable.
Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
- Implementation: Add
AsyncFnfamily of traits #119305 - Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- Unknown?
Related:
Footnotes
Reacted by Jana Dönszelmann, Cody Neiman, Martin Garton, Giovanni Bassi, Igor, Nícolas Varela Auler, Péter Kardos and Kamil Tomšík
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-needs-summaryStatus: It's hard to tell what's been done and what hasn't! Someone should do some investigation.Status: It's hard to tell what's been done and what hasn't! Someone should do some investigation.T-langRelevant to the language teamRelevant to the language teamT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Activity
9999years commentedon Sep 19, 2025
Here's a function you can express with
AsyncFnOnceand theFnOnceequivalent, which requires a second generic parameter:Jules-Bertholet commentedon Sep 19, 2025
related: #29625
workingjubilee commentedon Sep 19, 2025
Thanks for opening a tracking issue for this! I have linked the obvious PR but any other related PRs are not on my radar. cc @traviscross I believe you may know?
compiler-errors commentedon Sep 19, 2025
For
FnOnceit's fine, it's close enough and not harmful to write the bound in a two-partT: FnOnce() -> F, F: .... ForFn/FnMut, you'll lose the ability to return a future that borrows from its captures, which is basically the point of async closures in the first place.compiler-errors commentedon Sep 19, 2025
Not necessarily a comment for this tracking issue itself, but I believe the "idea" is to allow users to write RTN-style
T(..): ...bounds to bound the futures returned by async closures, see https://rust-lang.github.io/rfcs/3668-async-closures.html#interaction-with-return-type-notation-naming-the-future-returned-by-calling.target-san commentedon Apr 23, 2026
@compiler-errors Thing is, RTNs seem to be in "no ETA" state. This stabilization looks like a quite low-hanging fruit which will nevertheless resolve major pain point by allowing
I'm personally regularly forced to either not use async-like closures at all or build some strange workarounds exactly because I cannot express
Sendbound onAsyncFn/AsyncFnMutfuture. This arises extremely often when you write some kind of HTTP+database backend.cztomsik commentedon Sep 29, 2026
I've just got hit by this too. I was excited about async closures only to find out I cannot use them with tokio, because I can't restrict
Fand this is only allowed in nightly:BTW: possible workaround for anyone who ends up here. You can use tokio
LocalSet, and start a separate, top-level (and never-ending)Future, along with youraxum::serve, and then useselect!to wait until the server stops. That way, you can have something like cron scheduler and still be able to use async closures for your handlers, along with env capturing (my motivation).