Repository navigation
Tracking Issue for async_fn_in_trait, return_position_impl_trait_in_trait #91611
Description
Activity
- addedT-langRelevant to the language teamRelevant to the language teamC-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 RFC
on Dec 6, 2021 May I take a go at this?
Reacted by Yiyu Lin, Chris, Sherlock Holo, Xavier Groleau, Phuong Pham, Yuri Astrakhan, Kisaragi, Shane Tran Whitmire, Jonathan, Felipe Mica and 4 more- addedB-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.Blocker: Approved by a merged RFC but not yet implemented.F-async_fn_in_traitStatic async fn in traitsStatic async fn in traits
on Feb 5, 2022 Currently trying to take a stab at this. @rustbot claim
Reacted by Audun Halland, TennyZhuang, 李冬冬, Harrison Hemstreet and alexReacted by Baptiste Girardeau, TennyZhuang, Harrison Hemstreet and alex@LeSeulArtichaut actually, @spastorino has been looking into doing various refactorings to make this easier, you should probably synchronize with him, I'm not sure what state we are in.
Reacted by Léo Lanteri Thauvin and alexOhh, unsure why I've never assigned this to myself. I've been working on this since a while, and I've implemented RPITIT and async fns in traits support partially. At some point, we've realized that we wanted to change the design of the solution and started doing some refactors on RPITs.
Anyway, I've already talked with @LeSeulArtichaut, and I'd be happy to share some work with them about this feature or about any other feature ❤️LeSeulArtichaut commented
on Mar 24, 2022 on Mar 24, 2022 · Hidden as resolvedshow commentMore actions- addedS-tracking-impl-incompleteStatus: The implementation is incomplete.Status: The implementation is incomplete.
on Jul 27, 2022 It seems this has been asleep for a while, is it blocked? is it dead? Does it need more love?
@fakedrake we are working on this thing, there's some support work being done by my RPIT Refactor and by RPITIT PR that just landed. You can see discussions on https://rust-lang.zulipchat.com/#narrow/stream/330606-wg-async.2Fasync-fn-in-trait-impl
Reacted by Horváth Bálint, Tanner Davies, Adrián Delgado, Mihyaeru, Alberto Esposito, Cherry and alex30 remaining items
- changed the title
[-]Tracking Issue for return_position_impl_trait_in_trait, async_fn_in_trait[/-][+]Tracking Issue for async_fn_in_trait, return_position_impl_trait_in_trait[/+]on Jun 14, 2023 Is this still on track for 1.74, as mentioned by the blog post that had come out earlier?
Reacted by Dmitry Rusakov, ANIDENTIFIER, Alex, Cherry, Bilal Mahmoud, Ben Chuanlong Du, kk, Xuanwo and SurajReacted by Caio, Cherry and Andre JuliusReacted by Alex Forster, zz, Legokichi Duckscallion, David Skrundz, marziply, Pavel Atanasov, Jonas, Luka Maljic, ANIDENTIFIER, Cathal and 49 more- added a commit that references this issue
on Sep 5, 2023 Currently (on stable), anywhere you see an
async fn1, you know that it does no "work"2 when called, and only does work when.awaited or.poll()ed3. If it is allowed to manually desugarasync fnin a trait definition asfn() -> impl Futurein a trait impl, then this becomes no longer true, as one can insert computation into the function defintion, e.g.trait Trait { async fn foo(); } impl Trait for () { fn foo -> impl Future<Output = ()> { println!("Doing stuff!"); async {} } }
I don't think this is a "blocker" but perhaps that section of the async book and the reference could be updated to reflect this change.
Footnotes
-
outside of a macro ↩
-
For some defintion of "work" including anything but copying parameters into the return value ↩
-
This is my understanding at least, and it is somewhat supported by the
asyncbook and the Rust Reference: "The value returned byasync fnis aFuture. For anything to happen, theFutureneeds to be run on an executor." (emphasis mine) from the async book, and "Async functions do no work when called: instead, they capture their arguments into a future. When polled, that future will execute the function's body" (emphasis mine) from the Rust Reference ↩
Reacted by Daniel Henry-Mantilla, Faïz Hernawan, Lucas Vasilakopoulos, Inflation, Chayim Refael Friedman, Anhad Singh, runiq, Jonathan, Pavel Atanasov, Daniel Cormier and 4 more-
For the record, a stabilization PR has been opened over at: #115822.
#91611 (comment): @zachs18: Yeah, I think the async book should be adjusted to mention something along the lines of "future isn't, in general, gonna to be run to completion unless it is awaited" -- the point, afaict, is more to make sure folks know
.awaitneeds to be called on the future unlike other langs which spawn tasks and kick them off immediately as a part of theirasyncdesugaring or something.Reacted by Jonathan, Suraj, Haisham, Michael J Ward, Avon FitzGerald, Sofía Aritz, Filip T, Adhalianna, benjiegarcia, marziply and 3 moreReacted by Yosh, Michael J Ward, Avon FitzGerald, Maxime Guerreiro, 李冬冬, Honsun Zhu, Suraj, Dmitry Rodionov and Felipe S. S. SchneiderReacted by c3potheds, Diggory Hardy, Suraj, Dmitry Rodionov, Felipe S. S. Schneider and Arto BendikenReacted by Noah, Faïz Hernawan, PSeitz, Suraj and Felipe S. S. Schneider- added a commit that references this issue
on Oct 14, 2023 - added a commit that references this issue
on Jun 10, 2024 - added 2 commits that reference this issue
on Apr 2, 2025 - added a commit that references this issue
on May 1, 2026
impl Traitin traits" (Return positionimpl Traitin traits rfcs#3425).#![feature(async_fn_in_trait)].impl Traitin traits is#![feature(return_position_impl_trait_in_trait)].About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
async fnand return-positionimpl Traitin trait #115822Unresolved Questions
Async fn in trait
Return position impl Trait in trait
async fnto mitigate hazards of writing a trait that is not forwards-compatible with its desugaring?impl Traitto positions that are nameable using upcoming features like return-type notation (RTN)? (See this comment for an example.)Implementation history
Async fn in trait
F-async_fn_in_traitStatic async fn in traits
Return position impl Trait in trait
F-return_position_impl_trait_in_trait`#![feature(return_position_impl_trait_in_trait)]`
Several of these include code specific to async fn in trait.
impl Traitin traits #101224compare_predicate_entailmentno longer a query #101615impl Traitin traits are well-formed #101676impl Traitin traits #101679ProjectionTy::trait_def_idfor return-positionimpl Traitin trait correctly #102152impl Traitin trait hidden values in foreign libraries #102164impl Traitin trait #102334impl Traitin traits properly inregister_hidden_type#103355