Repository navigation
Tracking Issue for async_fn_in_trait, return_position_impl_trait_in_trait #91611
Copy link
Copy link
Closed
Closed
Copy link
Labels
B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.Blocker: Approved by a merged RFC but not yet implemented.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 RFCF-async_fn_in_traitStatic async fn in traitsStatic async fn in traitsF-return_position_impl_trait_in_trait`#![feature(return_position_impl_trait_in_trait)]``#![feature(return_position_impl_trait_in_trait)]`S-tracking-impl-incompleteStatus: The implementation is incomplete.Status: The implementation is incomplete.T-langRelevant to the language teamRelevant to the language team
Description
- This is a tracking issue for the RFC "static async fn in traits" (Static async fn in traits rfcs#3185) and "Return position
impl Traitin traits" (Return positionimpl Traitin traits rfcs#3425). - The feature gate for async fn in traits is
#![feature(async_fn_in_trait)]. - The feature gate for return position
impl Traitin traits is#![feature(return_position_impl_trait_in_trait)]. - This feature is developed as part of the async fundamentals initiative -- see that website for more information!
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
- Implement the RFC
- Adjust documentation (see instructions on rustc-dev-guide)
- Stabilization PR: Stabilize
async fnand return-positionimpl Traitin trait #115822
Unresolved Questions
Async fn in trait
Return position impl Trait in trait
- Should we stabilize this feature together with
async fnto mitigate hazards of writing a trait that is not forwards-compatible with its desugaring? - Resolution of RPITIT is allowed to name any in-scope lifetime parameter, unlike inherent RPIT methods #112194
- Note that this might impact the desugaring, as described in this comment.
- Should we limit the legal positions for
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_trait
- Only generate closure def id for async fns with body #102244
- Split out async_fn_in_trait into a separate feature #100734
Return position impl Trait in trait
F-return_position_impl_trait_in_trait
Several of these include code specific to async fn in trait.
- Initial implementation of return-position
impl Traitin traits #101224 - Equate fn outputs when inferring RPITIT hidden types #101614
- Make
compare_predicate_entailmentno longer a query #101615 - Check that the types in return position
impl Traitin traits are well-formed #101676 - Support default-body trait functions with return-position
impl Traitin traits #101679 - Calculate
ProjectionTy::trait_def_idfor return-positionimpl Traitin trait correctly #102152 - Resolve async fn signature even without body (e.g., in trait) #102161
- Serialize return-position
impl Traitin trait hidden values in foreign libraries #102164 - Avoid ICE in printing RPITIT type #102597
- Fix subst issues with return-position
impl Traitin trait #102334 - Handle return-position
impl Traitin traits properly inregister_hidden_type#103355
Reacted by Diego Barrios Romero, sksat, tema3210, 李冬冬, Nicolas Morlier, Tomáš Jašek, TennyZhuang, Achille Merendino, Sherlock Holo, Jakub Beránek and 180 more
Reacted by Yerkebulan Tulibergenov, TennyZhuang, Michael Watzko, Roman Valls Guimera, Audun Halland, Hyunsik Choi, Nils, Sayan, Felipe S. S. Schneider, Christopher Joel and 34 more
Reacted by Yerkebulan Tulibergenov, Michael Watzko, Roman Valls Guimera, Audun Halland, Hyunsik Choi, Nils, Sayan, Felipe S. S. Schneider, Christopher Joel, Shinichi Kogai and 29 more
Reacted by Konstantin Diachenko, Ivan S Glazunov, uselessgoddess, John-John Tedro, Yiyu Lin, Yerkebulan Tulibergenov, Roman Valls Guimera, Audun Halland, Hyunsik Choi, Tomas Sedlak and 35 more
Reacted by Felipe S. S. Schneider, Grzegorz Szeliga, Jamie, Ryo Onodera, Matheus Cardoso, Nguyen Thanh Dat, Andrew Hlynskyi, Guillaume E, Michalis Ioak, Anhad Singh and 4 more
Metadata
Metadata
Assignees
Labels
B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.Blocker: Approved by a merged RFC but not yet implemented.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 RFCF-async_fn_in_traitStatic async fn in traitsStatic async fn in traitsF-return_position_impl_trait_in_trait`#![feature(return_position_impl_trait_in_trait)]``#![feature(return_position_impl_trait_in_trait)]`S-tracking-impl-incompleteStatus: The implementation is incomplete.Status: The implementation is incomplete.T-langRelevant to the language teamRelevant to the language team
Activity
HTGAzureX1212 commentedon Feb 5, 2022
May I take a go at this?
LeSeulArtichaut commentedon Mar 23, 2022
Currently trying to take a stab at this. @rustbot claim
nikomatsakis commentedon Mar 24, 2022
@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.
spastorino commentedon Mar 24, 2022
Ohh, 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 commentedon Mar 24, 2022
fakedrake commentedon Sep 12, 2022
It seems this has been asleep for a while, is it blocked? is it dead? Does it need more love?
spastorino commentedon Sep 13, 2022
@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
30 remaining items
[-]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[/+]rakshith-ravi commentedon Aug 20, 2023
Is this still on track for 1.74, as mentioned by the blog post that had come out earlier?
fix(deps): update rust crate syn to v2 (#2512)
zachs18 commentedon Sep 13, 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.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 ↩compiler-errors commentedon Sep 14, 2023
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.Auto merge of rust-lang#115822 - compiler-errors:stabilize-rpitit, r=…
Switch to nightly rust for rust-lang/rust#91611
Set minimum Rust version.
Set 1.75 as minimal Rust version (#11821)
bump MSRV to 1.75 for RPITIT
bump MSRV to 1.75 for RPITIT
chore: bump MSRV to `1.75.0`
chore: bump MSRV to `1.75.0`
Set 1.75 as minimal Rust version (#11821)