Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking issue for IntoFuture #67644

Closed
Tracked by #16
seanmonstar opened this issue Dec 26, 2019 · 28 comments · Fixed by #98718
Closed
Tracked by #16

Tracking issue for IntoFuture #67644

seanmonstar opened this issue Dec 26, 2019 · 28 comments · Fixed by #98718
Labels
A-async-await Area: Async & Await AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. Libs-Tracked Libs issues that are tracked on the team's project board. S-tracking-ready-to-stabilize Status: This is ready to stabilize; it may need a stabilization report and a PR T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@seanmonstar
Copy link
Contributor

seanmonstar commented Dec 26, 2019

Introduced in #65244, this is a trait of a type that can be converted into a Future, used by .await (similar to how IntoIterator is used with for).

a more complete description can be found in #67644 (comment)

@Mark-Simulacrum Mark-Simulacrum added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. labels Dec 26, 2019
@Centril Centril added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label Dec 27, 2019
@jonas-schievink jonas-schievink added A-async-await Area: Async & Await B-unstable Blocker: Implemented in the nightly compiler and unstable. labels Dec 27, 2019
bors added a commit that referenced this issue Jan 3, 2020
…crum

Revert #65244 for performance reasons

This reverts commit f35517e.

Revert #65244 so we can see if it is the cause of the performance issue in #67706

cc #67644
@tmandry tmandry added the AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. label Jan 14, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue May 22, 2020
…akis

Add core::future::IntoFuture

This patch reintroduces the `core::future::IntoFuture` trait. However unlike earlier PRs this patch does not integrate it into the `async/.await` lowering since that lead to performance regressions. By introducing the trait separately from the integration, the integration PR can be more narrowly scoped, and people can start trying out the `IntoFuture` trait today. Thanks heaps!

cc/ @rust-lang/wg-async-foundations

## References
- Original PR adding `IntoFuture` rust-lang#65244
- Open issue to re-land `IntoFuture` (assigned to me) rust-lang#67982
- Tracking issue for `IntoFuture` rust-lang#67644
@KodrAus KodrAus added the Libs-Tracked Libs issues that are tracked on the team's project board. label Jul 31, 2020
@Fishrock123
Copy link
Contributor

Are there any blockers on this?

Surf would benefit from this, as presently, we use a kinda hacky work around with Options.

@Fishrock123
Copy link
Contributor

cc @yoshuawuyts who may have some context

@Aaron1011
Copy link
Member

This was implemented, but then reverted due to a performance regression. #69218 may help reduce the impact of implementing this.

@kushwahashiv
Copy link

how to use this in an app if I want to still use it

@kushwahashiv
Copy link

any update?

@ibraheemdev
Copy link
Member

ibraheemdev commented Aug 15, 2021

Trait was added back in #72459 and .await integration is tracked by #67982

eholk added a commit to eholk/rust that referenced this issue Nov 22, 2021
This is a reintroduction of the remaining parts from
rust-lang#65244 that have not been relanded
yet.

Issues rust-langGH-67644, rust-langGH-67982
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 3, 2021
Reintroduce `into_future` in `.await` desugaring

This is a reintroduction of the remaining parts from rust-lang#65244 that have not been relanded yet.

This isn't quite ready to merge yet. The last attempt was reverting due to performance regressions, so we need to make sure this does not introduce those issues again.

Issues rust-lang#67644, rust-lang#67982

/cc `@yoshuawuyts`
@WaffleLapkin
Copy link
Member

WaffleLapkin commented Dec 5, 2021

Just for a clarification (and to be similar to newer tracking issues)


Feature gate: #![feature(into_future)]

This is a tracking issue for the IntoFuture trait similar to IntoIterator allowing to convert types into futures.

Since #90737 this trait is also automatically used in expr.await desugaring allowing for code similar to the following (playground):

struct NotAFutureYet;

impl IntoFuture for NotAFutureYet {
    type Output = u8;
    type IntoFuture = Ready<Self::Output>;
    
    fn into_future(self) -> Self::IntoFuture {
        ready(42)
    }
}

async fn test() {
    assert_eq!(NotAFutureYet.await, 42);
}

Public API

// core::future

pub trait IntoFuture {
    type Output;
    type IntoFuture: Future<Output = Self::Output>;

    fn into_future(self) -> Self::IntoFuture;
}

Steps / History

Unresolved Questions

  • None yet.

@WaffleLapkin
Copy link
Member

I wonder though if the method should be called into_fut to be more consistent with into_iter (note that it's not called into_iterator)

@yoshuawuyts
Copy link
Member

yoshuawuyts commented Dec 6, 2021

I wonder though if the method should be called into_fut to be more consistent with into_iter (note that it's not called into_iterator)

@WaffleLapkin I don't think we should; "future" is a pretty short name already. The "iterator" submodule is named core::iter and the "future" submodule is named core::future. Even if we shorten "future" to "fut" for this API, we wouldn't be able to consistently match how it's used for iterator. I feel that inconsistency might throw people off, and it'd be better if we keep using "future" everywhere.


@rust-lang/libs-api now that #67982 has landed .await now desugars using IntoFuture as per RFC 2394. This means two years after the current version of IntoFuture landed on nightly the last blocker for it has been resolved!

I'd like to propose we FCP IntoFuture for stabilization. Rust 1.59 will be using the new .await desugaring, and it'd be great if the trait it desugars into is also available on stable.

@dtolnay
Copy link
Member

dtolnay commented Dec 6, 2021

👎 I'd veto stabilizing IntoFuture in the same release as the desugaring change. I don't know of any technical reason that the desugaring and trait benefit from being stabilized in the same release. I know the trait is old, but it hasn't been used in .await so far. Let's give users a chance to write code against this on nightly and uncover any resulting API awkwardness. The desugaring change can be amended or rolled back at any point because impl<F: Future> IntoFuture for F is the only impl built into core that a stable .await could make use of.

@yoshuawuyts
Copy link
Member

@dtolnay that seems reasonable; happy to revisit this in a couple of months.

@rfcbot rfcbot added the disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. label Jun 8, 2022
@yoshuawuyts
Copy link
Member

@yaahc It appears both T-lang and T-libs-api members have been tagged on the merge proposal. In #67644 (comment) you mentioned that the right team to review this would be T-libs-api. Should T-lang be untagged?

@dtolnay
Copy link
Member

dtolnay commented Jun 8, 2022

Both is correct given that this affects meaning of .await language syntax.

@nikomatsakis
Copy link
Contributor

@rfcbot reviewed

This is great, looking forward to this.

compiler-errors added a commit to compiler-errors/rust that referenced this issue Jun 9, 2022
…nTitor,yaahc

update docs for `std::future::IntoFuture`

Ref rust-lang#67644.

This updates the docs for `IntoFuture` providing a bit more guidance on how to use it. Thanks!
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jun 10, 2022
…nTitor,yaahc

update docs for `std::future::IntoFuture`

Ref rust-lang#67644.

This updates the docs for `IntoFuture` providing a bit more guidance on how to use it. Thanks!
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jun 10, 2022
…nTitor,yaahc

update docs for `std::future::IntoFuture`

Ref rust-lang#67644.

This updates the docs for `IntoFuture` providing a bit more guidance on how to use it. Thanks!
@yoshuawuyts
Copy link
Member

ping @Amanieu, @cramertj, @m-ou-se - can I ask you to take a look at this when you have time?

@joshtriplett joshtriplett added the I-libs-api-nominated The issue / PR has been nominated for discussion during a libs-api team meeting. label Jun 20, 2022
@rfcbot rfcbot added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Jun 22, 2022
@rfcbot
Copy link

rfcbot commented Jun 22, 2022

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Jun 22, 2022
@joshtriplett joshtriplett removed the I-libs-api-nominated The issue / PR has been nominated for discussion during a libs-api team meeting. label Jun 22, 2022
@joshtriplett joshtriplett added the S-tracking-ready-to-stabilize Status: This is ready to stabilize; it may need a stabilization report and a PR label Jun 29, 2022
@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Jul 2, 2022
@rfcbot
Copy link

rfcbot commented Jul 2, 2022

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@rfcbot rfcbot added the to-announce Announce this issue on triage meeting label Jul 2, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jul 8, 2022
…r=yaahc

Stabilize `into_future`

rust-lang#67644 has been labeled with [S-tracking-ready-to-stabilize](https://github.com/rust-lang/rust/labels/S-tracking-ready-to-stabilize) - which mentions someone needs to file a stabilization PR. So hence this PR! ✨ Thanks!

Closes rust-lang#67644

r? `@joshtriplett`
@bors bors closed this as completed in 9c6bcb6 Jul 8, 2022
@jonhoo
Copy link
Contributor

jonhoo commented Jul 8, 2022

I'm guessing this should be tagged with relnotes, or does to-announce already imply that?

@yaahc
Copy link
Member

yaahc commented Jul 8, 2022

I'm guessing this should be tagged with relnotes, or does to-announce already imply that?

👍, David went and tagged the PR

@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Sep 8, 2022
workingjubilee pushed a commit to tcdi/postgrestd that referenced this issue Sep 15, 2022
update docs for `std::future::IntoFuture`

Ref rust-lang/rust#67644.

This updates the docs for `IntoFuture` providing a bit more guidance on how to use it. Thanks!
workingjubilee pushed a commit to tcdi/postgrestd that referenced this issue Sep 15, 2022
Stabilize `into_future`

rust-lang/rust#67644 has been labeled with [S-tracking-ready-to-stabilize](https://github.com/rust-lang/rust/labels/S-tracking-ready-to-stabilize) - which mentions someone needs to file a stabilization PR. So hence this PR! ✨ Thanks!

Closes rust-lang/rust#67644

r? ``@joshtriplett``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. Libs-Tracked Libs issues that are tracked on the team's project board. S-tracking-ready-to-stabilize Status: This is ready to stabilize; it may need a stabilization report and a PR T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.