-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Remove coroutine info when building coroutine drop body #120330
Remove coroutine info when building coroutine drop body #120330
Conversation
r? @nnethercote (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
This comment has been minimized.
This comment has been minimized.
eca402b
to
7f9648d
Compare
@@ -1,25 +1,4 @@ | |||
// MIR for `main::{closure#0}` 0 coroutine_drop | |||
/* coroutine_layout = CoroutineLayout { |
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.
(Unsurprisingly, coroutine layout is not present in the drop shim body anymore. This does affect the MIR dump, but does not affect the drop's codegen.)
@@ -303,6 +308,7 @@ pub struct Body<'tcx> { | |||
/// and used for debuginfo. Indexed by a `SourceScope`. | |||
pub source_scopes: IndexVec<SourceScope, SourceScopeData<'tcx>>, | |||
|
|||
/// Additional information carried by a MIR body when it is lowered from a coroutine. |
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.
Brief mention of when it goes from Some
to None
would be good.
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.
So this never goes from Some
to None
for normal MIR bodies. The only reason it "goes from Some
to None
" when we're building the coroutine drop shim is because we're cloning the whole MIR body struct (presumably out out of convenience) rather than, for example, just copying the basic blocks and locals into a fresh body.
The idea is that this is just basically "take what we can from the parent MIR body, and then just fix up what is wrong". Other body information is patched up at the same time, such as the source
and arg_count
, and I don't believe that it makes sense to leave a parallel comment on arg_count
, for example.
I can leave a comment on the take
call below though.
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.
That would be great info to put into the comment! E.g. "Some
" in the normal case, None
only when we're building the coroutine drop shim".
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.
None only when we're building the coroutine drop shim
And every other MIR body, not just coroutine drop shims. Which is why I think it feels redundant to note this, since this already says "when it is lowered from a coroutine".
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.
The final version looks fine, thanks!
r=me with the nits addressed. |
7f9648d
to
56fe4d6
Compare
56fe4d6
to
07b7c77
Compare
that should be sufficient @bors r=nnethercote |
…in-coroutine-drop-body, r=nnethercote Remove coroutine info when building coroutine drop body Coroutine drop shims are not themselves coroutines, so erase the "`coroutine`" field from the body so that helper fns like `yield_ty` and `coroutine_kind` properly return `None` for the drop shim.
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#118208 (Rewrite the BTreeMap cursor API using gaps) - rust-lang#120099 (linker: Refactor library linking methods in `trait Linker`) - rust-lang#120165 (Switch `NonZero` alias direction.) - rust-lang#120288 (Bump `askama` version) - rust-lang#120306 (Clean up after clone3 removal from pidfd code (docs and tests)) - rust-lang#120316 (Don't call `walk_` functions directly if there is an equivalent `visit_` method) - rust-lang#120330 (Remove coroutine info when building coroutine drop body) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#118208 (Rewrite the BTreeMap cursor API using gaps) - rust-lang#120099 (linker: Refactor library linking methods in `trait Linker`) - rust-lang#120288 (Bump `askama` version) - rust-lang#120306 (Clean up after clone3 removal from pidfd code (docs and tests)) - rust-lang#120316 (Don't call `walk_` functions directly if there is an equivalent `visit_` method) - rust-lang#120330 (Remove coroutine info when building coroutine drop body) - rust-lang#120332 (Remove unused struct) - rust-lang#120338 (Fix links to [strict|exposed] provenance sections of `[std|core]::ptr`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#120330 - compiler-errors:no-coroutine-info-in-coroutine-drop-body, r=nnethercote Remove coroutine info when building coroutine drop body Coroutine drop shims are not themselves coroutines, so erase the "`coroutine`" field from the body so that helper fns like `yield_ty` and `coroutine_kind` properly return `None` for the drop shim.
Coroutine drop shims are not themselves coroutines, so erase the "
coroutine
" field from the body so that helper fns likeyield_ty
andcoroutine_kind
properly returnNone
for the drop shim.