Dispatch MIR pipeline by BodyOwnerKind instead of const context#155808
Dispatch MIR pipeline by BodyOwnerKind instead of const context#155808lapla-cogito wants to merge 1 commit intorust-lang:mainfrom
BodyOwnerKind instead of const context#155808Conversation
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
|
|
Hmmm. We shouldn't ever invoke optimized_mir on const closures defined in const items I think? Tho I guess with an opaque type as the const's type we could indeed return a const closure. Or just via a const item of fn ptr type? I'll need to think about this some more, but if you have any thoughts about it lmk. Please add tests for both of these situations, too. |
This comment has been minimized.
This comment has been minimized.
dc90d1f to
48dc828
Compare
Is this because const items are only evaluated during CTFE (IIUC)? If so, the examples you mention are counterexamples.
I've added a test for the fn ptr type variant, which causes an ICE on current nightly. I also tried opaque-type variants, but they were rejected by unrelated checks before reaching the ICE path 🤔 |
fixes #155803
Since e8a4611,
hir_body_const_context()returns the parent's const context for aconstclosure. Howeverinner_optimized_mir()andinner_mir_for_ctfe()were usinghir_body_const_context()to decide which MIR pipeline a body goes through. With the new semantics, a const closure nested in a const item gets classified as a constant, so under-Clink-dead-codewe either hit "do not useoptimized_mirfor constants" or steal a body thatoptimized_mirstill needs.r? oli-obk (since you authored the commit mentioned above, feel free to reroll)