-
Notifications
You must be signed in to change notification settings - Fork 14.1k
-Zfused-futures #147129
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
-Zfused-futures #147129
Conversation
This comment has been minimized.
This comment has been minimized.
4f27364 to
6bc1534
Compare
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
r? @nnethercote rustbot has assigned @nnethercote. Use |
This feels fishy as a compiler flag tbh |
I agree. I'm no expert on futures and coroutines, but this feels like a very quick and dirty partial solution to the problem, with low discoverability and no clear path to a cleaner, more general solution. Maybe |
|
To elaborate, I would expect this to at least be visible somehow in the source language so it does not catch the reader completely off guard. I do not have a good grasp on what that would look like, perhaps an attribute, perhaps some other syntactical notation. The point is, however, with a compiler flag like this, we get completely different runtime semantics for the same source program. For instance, if you have some unsafe code which relies on the This feels very surprising that I wouldn't even want to land this as-is as an unstable compiler flag. Especially given there's no way this present approach would be stabilized IMHO. |
| #![allow(unused)] | ||
|
|
||
| // EMIT_MIR fused_futures.future-{closure#0}.coroutine_resume.0.mir | ||
| pub async fn future() -> u32 { |
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.
Does this need to be pub?
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.
Probably not
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.
Casual observer here, I think returning Poll::Pending and hang-forever is not a good idea, this is equivalent to silent failure, which makes the trouble-shooting more difficult on complicated system.
Maybe a better way would be some sort of a global handler (hello, externally implementable items #125418), but at this point it feels a bit like reinventing
This is why it is opt-in. Maybe something like a |
(FWIW I am the one who filed #147041 ) I feel like the attribute way would be cleaner and clearer as well. However I don't like either tbh. I have no idea how hard it is in terms of implementation and/or pushing it toward stabilization, but the attribute could make some more drastic behavioral changes, such as changing the |
|
I think opening a discussion on Zulip might be worthwhile for this topic. |
|
Currently the documentation of
All futures to date have been written according to this definition. Changing that to now also capture "done" semantics is not backwards-compatible and will cause breakage in the ecosystem. Speaking as a maintainer of I believe the solution proposed here should be rejected on compatibility grounds. The fact that those semantics are hidden behind a flag obscures this somewhat; but if we make this an option people can toggle library authors will have to assume some people will enable it. And that means that code that works perfectly fine today will need to be updated because Rust changed its semantics. And that's the kind of breakage that Rust promises not to make. |
In my opinion, It may not be a good choice to introduce this opt-in flag that creates possibilities of silent failures. |
|
It feels like there is consensus that this flag isn't the right solution to this problem, so I'm going to close it. Thanks for the attempt, @GrigorenkoPV! Starting Zulip discussions about an attribute might be a good path forward from here. |
Fixes (kinda) #147041
Introduces
-Zfused-futures, a flag that makes compiler-generated futures returnPoll::Pendinginstead of panicking when polled after completion.