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
Generator Resume Arguments #68524
Generator Resume Arguments #68524
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
This comment has been minimized.
4fa2c0e
to
a86373f
Compare
This comment has been minimized.
This comment has been minimized.
a86373f
to
7620e7e
Compare
This comment has been minimized.
This comment has been minimized.
7620e7e
to
239e313
Compare
This comment has been minimized.
This comment has been minimized.
239e313
to
6795f59
Compare
This comment has been minimized.
This comment has been minimized.
6795f59
to
b1944ab
Compare
TerminatorKind::Yield { ref value, .. } => { | ||
TerminatorKind::Yield { ref value, resume_arg: ref place, .. } => { | ||
self.create_move_path(place); | ||
self.gather_init(place.as_ref(), InitKind::Deep); |
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.
I noticed that the order of gather_init
and gather_operand
is swapped compared to DropAndReplace
, but I'm not sure if it matters.
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 |
I think an assocated type makes more sense, as it is very unlikely to ever be overloaded for different resume types. |
Async generators (should) implement |
|
…Zoxc Generator Resume Arguments cc #43122 and #56974 Blockers: * [x] Fix miscompilation when resume argument is live across a yield point (#68524 (comment)) * [x] Fix 10% compile time regression in `await-call-tree` benchmarks (#68524 (comment)) * [x] Fix remaining 1-3% regression (#68524 (comment)) - resolved (#68524 (comment)) * [x] Make dropck rules account for resume arguments (#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)
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 |
|
01de4ae
to
9d7b214
Compare
It does not have unwinding support
@bors r=Zoxc |
|
…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
@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 :) |
@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?:
|
@pitaj The resume argument works like a closure argument, you can give it an explicit type like |
cc #43122 and #56974
Blockers:
await-call-tree
benchmarks (#68524 (comment))Follow-up work:
box_region.rs
to use resume arguments (this shows up in profiles too)