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

add IntoFuture trait and support for await #65244

Merged
merged 1 commit into from
Dec 28, 2019

Conversation

seanmonstar
Copy link
Contributor

The async-await RFC mentions being able to await anything implementing IntoFuture. Somewhere along the way, it was left out.

@rust-highfive

This comment has been minimized.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 9, 2019
@Centril Centril added relnotes Marks issues that should be documented in the release notes of the next release. 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. needs-rfc This change is large or controversial enough that it should have an RFC accepted before doing it. needs-fcp This change is insta-stable, so needs a completed FCP to proceed. and removed needs-rfc This change is large or controversial enough that it should have an RFC accepted before doing it. labels Oct 9, 2019
@Centril
Copy link
Contributor

Centril commented Oct 9, 2019

r? @nikomatsakis cc @cramertj

@rust-highfive rust-highfive assigned nikomatsakis and unassigned kennytm Oct 9, 2019
@seanmonstar
Copy link
Contributor Author

(My machine dies trying to compile rustc, so I'll be needing CI to tell me if I goofed a small thing. And I can add a tracking issue if accepted.)

@rust-highfive

This comment has been minimized.

nikomatsakis
nikomatsakis previously approved these changes Oct 9, 2019
Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code generally looks good to me -- though I feel like the test ought not to be passing. Let's see what travis says.

Anyway, the other question is whether we want to enable this. It'd be good to capture some of the motivation. The main thing I've heard (which I find persuasive) came from the async-finalizers blog post by @yoshuawuyts. The main reason I've heard for removing IntoFuture was basically "YAGNI" -- not sure if there were more motivations than that? (Maybe @withoutboats remembers?)

src/test/ui/async-await/await-into-future.rs Show resolved Hide resolved
@@ -99,6 +99,18 @@ pub trait Future {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>;
}

/// Conversion into a `Future`.
#[unstable(feature = "into_future", issue = "0")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should file a tracking issue, but let's hold off just a bit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a tracking issue before this gets merged, though, I think.

@cramertj
Copy link
Member

cramertj commented Oct 9, 2019

I don't think it was forgotten about-- IntoFuture was intentionally removed from futures-rs a while back because the only things left that implemented it were tuple types. I'm not opposed to this PR at all; I don't know of any serious downsides to providing this functionality, aside from potentially yet another layer of indirection for error messages. However, I am curious to see what use-cases you have in mind for it!

@nikomatsakis
Copy link
Contributor

@cramertj did you see the async-finalizers (since renamed to async-builders, I think) blog post I was referring to? That's at least one use case.

(I'd like to know if @seanmonstar had another use case in mind, though!)

@seanmonstar
Copy link
Contributor Author

Yes, I've long had various builders in reqwest and hyper that I've previously felt would be nice if they could easily become futures, but they themselves aren't futures.

(My office internet is flaking hard, so might take a bit to update the PR.)

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@seanmonstar seanmonstar force-pushed the into-future branch 2 times, most recently from bd3eb16 to 5e3d3bb Compare October 9, 2019 21:59
@rust-highfive

This comment has been minimized.

@seanmonstar
Copy link
Contributor Author

@bors r+

@bors
Copy link
Contributor

bors commented Dec 27, 2019

📌 Commit f35517e has been approved by seanmonstar

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. labels Dec 27, 2019
oli-obk added a commit to oli-obk/rust that referenced this pull request Dec 27, 2019
add IntoFuture trait and support for await

The [async-await RFC](https://rust-lang.github.io/rfcs/2394-async_await.html#the-await-compiler-built-in) mentions being able to `await` anything implementing `IntoFuture`. Somewhere along the way, it was left out.
bors added a commit that referenced this pull request Dec 28, 2019
Rollup of 15 pull requests

Successful merges:

 - #65244 (add IntoFuture trait and support for await)
 - #67576 (reuse `capacity` variable in slice::repeat)
 - #67588 (Use NonNull in slice::Iter and slice::IterMut.)
 - #67594 (Update libc to 0.2.66)
 - #67602 (Use issue = "none" instead of "0" in intrinsics)
 - #67604 (Add Scalar::to_(u|i)16 methods)
 - #67617 (Remove `compiler_builtins_lib` documentation)
 - #67621 (Use the correct type for static qualifs)
 - #67629 (Remove redundant link texts)
 - #67632 (Convert collapsed to shortcut reference links)
 - #67633 (Update .mailmap)
 - #67635 (Document safety of Path casting)
 - #67654 (Add regression test for old NLL ICE)
 - #67659 (Stabilize the `matches!` macro)
 - #67664 (Fix some mailmap entries)

Failed merges:

r? @ghost
@bors
Copy link
Contributor

bors commented Dec 28, 2019

⌛ Testing commit f35517e with merge 3a087ad...

@bors
Copy link
Contributor

bors commented Dec 28, 2019

☔ The latest upstream changes (presumably #67670) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 28, 2019
@bors bors merged commit f35517e into rust-lang:master Dec 28, 2019
bors added a commit that referenced this pull request 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
bors added a commit that referenced this pull request Feb 3, 2020
Re-land "add IntoFuture trait and support for await"

Testing the code from #65244 to see if the performance regressions are still there. #68606 and #68672 made perf optimizations that might interact with this change.

If this lands, fixes #67982.

cc @seanmonstar @jonas-schievink
r? @cramertj
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request 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
eholk added a commit to eholk/rust that referenced this pull request 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 pull request 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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. needs-fcp This change is insta-stable, so needs a completed FCP to proceed. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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 this pull request may close these issues.