-
Notifications
You must be signed in to change notification settings - Fork 647
Fix pinned boxed async functions #916
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
Conversation
42f3f4e
to
9244ed7
Compare
I made the |
9244ed7
to
2bf24a3
Compare
It's working for me pretty well, can you please merge this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just want to clarify why the additional re-exports.
@@ -264,6 +264,15 @@ pub mod prelude { | |||
#[cfg(feature = "std")] | |||
pub use futures_core::executor::Executor; | |||
|
|||
#[cfg(feature = "nightly")] | |||
pub use futures_stable::{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't these already exported through the stable
submodule?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to put them into futures::prelude
as normal Future
and Stream
so that users don't need to use
them every time in modules which use #[async]
stuff otherwise they'll see some error messages about missing methods of pin()
or pin_local()
.
This code doesn't work for me (it works if one of the parameters is #[async(pinned)]
fn bar2(x: &i32, y: &i32) -> Result<i32, i32> {
Ok(x+y)
} It fails with the following error: error[E0226]: only a single explicit lifetime bound is permitted
--> futures/tests/async_await/pinned.rs:16:45
|
16 | fn bar2(x: &i32, y: &i32) -> Result<i32, i32> {
| ^
error[E0623]: lifetime mismatch
--> futures/tests/async_await/pinned.rs:16:30
|
16 | fn bar2(x: &i32, y: &i32) -> Result<i32, i32> {
| ---- ^^^^^^^^^^^^^^^^
| | |
| | ...but data from `y` is returned here
| this parameter and the return type are declared with different lifetimes... EDIT: EDIT 2: |
@ngg's first error is because The expansion of lifetimes needs to be changed to instead of just adding #[async] fn foo(x: &i32, y: &i32) -> Result<i32, !> { ... }
// currently:
fn foo<'_async0, '_async1>(x: &'_async0 i32, y: &'_async1 i32)
-> impl Future<Item = i32, Error = !> + '_async0 + '_async1 { ... }
// changed to:
fn foo<'_ret, '_async0: '_ret, '_async1: '_ret>(x: &'_async0, y: &'_async1 i32)
-> impl Future<Item = i32, Error = !> + '_ret { ... } |
Its a separate issue from this PR though! |
See rust-lang/rust#49431 for a rust issue about |
Yeah I realized it's different but only after writing this here. (I wrongly remembered that it was working with normal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -264,6 +264,15 @@ pub mod prelude { | |||
#[cfg(feature = "std")] | |||
pub use futures_core::executor::Executor; | |||
|
|||
#[cfg(feature = "nightly")] | |||
pub use futures_stable::{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to put them into futures::prelude
as normal Future
and Stream
so that users don't need to use
them every time in modules which use #[async]
stuff otherwise they'll see some error messages about missing methods of pin()
or pin_local()
.
0258ca7
to
9f5acf4
Compare
@raviqqe I reverted it pretty fast when I realized you already did it and that Nemo157@5c32c05 is based on your version. I actually prefer your solution with not creating |
9f5acf4
to
7d5a4c6
Compare
Will merge if tests pass, thanks for this! |
one failure, missing |
Merged, thanks so much for doing this! 🎉 |
This change fixes pinned boxed async functions which were unable to compile.