-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
MIR required_consts, mentioned_items: ensure we do not forget to fill these lists #128494
Conversation
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
This currently ICEs for async closures, looks like we do indeed forget to compute these lists there. @compiler-errors do async closures not go through the normal MIR passes? In that case they have to manually invoke the right passes to compute required_consts and mentioned_items. Where should that be done? |
Async drop also doesn't seem to compute the required_consts. EDIT: the failing test is async-closures/drop.rs, so actually that's probably also just the async closures issue. |
5d5dceb
to
824dd75
Compare
This comment has been minimized.
This comment has been minimized.
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.
Good change 👍
@bors r+ |
Oops, didn't see this was still failing. @bors r- |
Yeah I need your help to fix this I think. :) Async closure MIR doesn't seem to set these lists, any idea where that might be going wrong? |
They should go through normal MIR passes. We copy the body here:
So any passes previously applied should still be okay. Then on subsequent passes, we apply the pass to the rust/compiler/rustc_mir_transform/src/pass_manager.rs Lines 186 to 190 in 97ac52f
Are we not populating |
No those are not normal passes.
|
Wait so when passes are applied to one body we actually apply them to another? What a glorious hack.^^ But super hard to follow... |
Hm. So I guess we could just manually handle the async closure "by move" body manually for both passes, but I fear that we'll just forget to apple some other special pass in the future just like these two.
It's the only way that I saw for us to ensure that we're applying all the same passes to the original async closure and the "by move" body in lockstep, since the latter is generated on the fly really early during |
Not even required_consts are set which are usually set very early in MIR construction, so it also seems like this doesn't go through the normal MIR builder, or so? The by-move body should just be its proper independent own MIR, and then when a query asks for that MIR it should go through the pass manager itself. Why should it "ride along" the other body? |
Perhaps I should just bite the bullet and synthesize real def ids for async closure "by move" bodies so I can just feed I guess you can probably do whatever to unblock this, or if you have better ideas I'd love to hear them. |
Yes, I think that's what I meant. Having one DefId refer to two bodies seems like a recipe for confusion. It's already bad enough with const MIR and runtime MIR, let's not add another dimension.^^ |
Though some drop shims also seem to bypass that pass manager, not sure what's going on there...
|
It's arguable to say that drop shim has a proper def id. It uses the def id of But that's kinda unrelated. I'll look into getting this fixed the right way, but it may be much harder than it seems, so it's up to you if you want to block this PR on that work. |
What's luckily different from the drop shim is that the by-move body doesn't need to be generated after the coroutine transformation pass, so we may be lucky and it turns out much simpler than expected :D |
The first problem is earlier -- the body we see and clone in ByMoveBody already doesnt have its required_consts set. So something is already going wrong before that. |
Oh wait, is mir_built before mir_promoted? In that case that's expected, I guess. Even the pass manager for normal MIR is already such a mess, it's near impossible to remember what happens in which order.^^ |
824dd75
to
6d312d7
Compare
Let's see, hopefully this is enough. |
It's magic, but knowing that it is
No idea what you mean here. The |
I'm talking about why we have https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/enum.InstanceKind.html#method.has_polymorphic_mir_body, because the body you get back from |
I think we can agree that drops shims and asyn-by move bodies are both cursed, each in their own unique ways. :) I hope that what this PR does now works. It's a hack, but we should notice fairly easily when it goes wrong (that's exactly why the first version of the PR ICEd). |
…r-errors MIR required_consts, mentioned_items: ensure we do not forget to fill these lists Bodies initially get created with empty required_consts and mentioned_items, but at some point those should be filled. Make sure we notice when that is forgotten.
Rollup of 5 pull requests Successful merges: - rust-lang#127276 (rustdoc: Remove OpaqueTy) - rust-lang#128404 (Revert recent changes to dead code analysis) - rust-lang#128466 (Update the stdarch submodule) - rust-lang#128483 (Still more `cfg` cleanups) - rust-lang#128494 (MIR required_consts, mentioned_items: ensure we do not forget to fill these lists) r? `@ghost` `@rustbot` modify labels: rollup
…r-errors MIR required_consts, mentioned_items: ensure we do not forget to fill these lists Bodies initially get created with empty required_consts and mentioned_items, but at some point those should be filled. Make sure we notice when that is forgotten.
…r-errors MIR required_consts, mentioned_items: ensure we do not forget to fill these lists Bodies initially get created with empty required_consts and mentioned_items, but at some point those should be filled. Make sure we notice when that is forgotten.
Rollup of 7 pull requests Successful merges: - rust-lang#122049 (Promote riscv64gc-unknown-linux-musl to tier 2) - rust-lang#128147 (migrate fmt-write-bloat to rmake) - rust-lang#128161 (nested aux-build in tests/rustdoc/ tests) - rust-lang#128404 (Revert recent changes to dead code analysis) - rust-lang#128466 (Update the stdarch submodule) - rust-lang#128483 (Still more `cfg` cleanups) - rust-lang#128494 (MIR required_consts, mentioned_items: ensure we do not forget to fill these lists) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#126818 (Better handle suggestions for the already present code and fix some suggestions) - rust-lang#128436 (Update sysinfo version to 0.31.2) - rust-lang#128453 (raw_eq: using it on bytes with provenance is not UB (outside const-eval)) - rust-lang#128491 ([`macro_metavar_expr_concat`] Dogfooding) - rust-lang#128494 (MIR required_consts, mentioned_items: ensure we do not forget to fill these lists) - rust-lang#128521 (rustdoc: Remove dead opaque_tys rendering logic) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#128494 - RalfJung:mir-lazy-lists, r=compiler-errors MIR required_consts, mentioned_items: ensure we do not forget to fill these lists Bodies initially get created with empty required_consts and mentioned_items, but at some point those should be filled. Make sure we notice when that is forgotten.
Bodies initially get created with empty required_consts and mentioned_items, but at some point those should be filled. Make sure we notice when that is forgotten.