Uh oh!
There was an error while loading. Please reload this page.
Generator Resume Arguments - #68524
Conversation
rust-highfive
commented
Jan 24, 2020
(rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
petrochenkov
commented
Jan 24, 2020
Glad to see this implemented, but it is not my area of expertise. r? @Zoxc for review or further reassignment. |
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
I noticed that the order of gather_init and gather_operand is swapped compared to DropAndReplace, but I'm not sure if it matters.
Zoxc
commented
Jan 25, 2020
I think I'd prefer to make this PR make the argument be a type parameter instead of a associated type before landing to avoid some unnecessary churn in the compiler and for users of generators. I also don't know how correct this is with regards to drops and references, but those concerns could be delayed by just adding a |
bjorn3
commented
Jan 25, 2020
I think an assocated type makes more sense, as it is very unlikely to ever be overloaded for different resume types. |
matthewjasper
commented
Jan 25, 2020
Async generators (should) implement |
This comment has been minimized.
This comment has been minimized.
jonas-schievink
commented
Jan 25, 2020
Done!
True, but I'd prefer to not limit this feature to what async/await needs (that always leaves a sour taste in my mouth). I'm willing to add more tests, if you (or anyone else) have any suggestions for what needs to be tested here. The current tests are fairly minimal, but I did add some drop tests. |
jonas-schievink
commented
Jan 26, 2020
There's still a lingering miscompilation somewhere: letmut g = |mut d| {
d = yield;};This ends up dropping Could this be because the transform assumes there will be at least one |
jonas-schievink
commented
Jan 26, 2020
Let's see if the @bors try @rust-timer queue |
rust-timer
commented
Jan 26, 2020
Awaiting bors try build completion |
Zoxc
commented
Feb 6, 2020
@bors r+ |
bors
commented
Feb 6, 2020
📌 Commit 732913a has been approved by |
bors
commented
Feb 6, 2020
⌛ Testing commit 732913a with merge 003534dfa96de6c33f99b0ce3fc2c16456878039... |
rust-highfive
commented
Feb 6, 2020
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
bors
commented
Feb 6, 2020
💔 Test failed - checks-azure |
It does not have unwinding support
jonas-schievink
commented
Feb 6, 2020
@bors r=Zoxc |
bors
commented
Feb 6, 2020
📌 Commit 9d7b214 has been approved by |
…guments, r=Zoxc Generator Resume Arguments cc rust-lang#43122 and rust-lang#56974 Blockers: * [x] Fix miscompilation when resume argument is live across a yield point (rust-lang#68524 (comment)) * [x] Fix 10% compile time regression in `await-call-tree` benchmarks (rust-lang#68524 (comment)) * [x] Fix remaining 1-3% regression (rust-lang#68524 (comment)) - resolved (rust-lang#68524 (comment)) * [x] Make dropck rules account for resume arguments (rust-lang#68524 (comment)) Follow-up work: * Change async/await desugaring to make use of this feature * Rewrite [`box_region.rs`](https://github.com/rust-lang/rust/blob/3d8778d767f0dde6fe2bc9459f21ead8e124d8cb/src/librustc_data_structures/box_region.rs) to use resume arguments (this shows up in profiles too)
Rollup of 6 pull requests Successful merges: - #67359 (Rename -Zexternal-macro-backtrace to -Zmacro-backtrace and clean up implementation.) - #68524 (Generator Resume Arguments) - #68791 (implement proper linkchecker hardening) - #68886 (Mark fn map_or() as eagerly evaluated.) - #68888 (error code examples: replace some more ignore with compile_fail) - #68894 (Update E0565 examples) Failed merges: r? @ghost
semtexzv
commented
Feb 12, 2020
@jonas-schievink Thanks for the change, I'd be interested about how it relates to the discussion in rust-lang/rfcs#2781 , I'd love to have your input :) |
jonas-schievink
commented
Feb 12, 2020
@semtexzv I don't really have the energy to partake in RFC discussions, but I seem to have implemented the second option described in rust-lang/rfcs#2781 (comment) in this PR |
@jonas-schievink as far as I can tell, this PR doesn't introduce any generator syntax for defining the types of resume arguments and yield values. It still relies on type inference to get those types, right? What would a maximally qualified generator look like now? Something like this?: |
jonas-schievink
commented
Jun 4, 2020
@pitaj The resume argument works like a closure argument, you can give it an explicit type like |
cc #43122 and #56974
Blockers:
await-call-treebenchmarks (Generator Resume Arguments #68524 (comment))Follow-up work:
box_region.rsto use resume arguments (this shows up in profiles too)