mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-01 17:40:16 +00:00
Introduce `TypingMode::Codegen` to avoid layout cycles on coroutines Computing layout of coroutines depends on their `optimized_mir`. At the same time, MIR opts can require using layouts to work. For instance to evaluate constants. This leads to cycles and clumsy workarounds. This PR creates a new typing mode for layout computations: - when a coroutine's layout is requested with `TypingMode::PostAnalysis` or earlier, return `LayourError::TooGeneric`; - when a coroutine's layout is requested with `TypingMode::Codegen`, actually compute it. `TypingMode::Codegen` is meant be be used by codegen code, and analyses that require coroutine layout, like transmute check and coroutine recursion check. With this PR, we can remove all `is_coroutine` checks from `rustc_mir_transform` and unlock simplifying coroutine MIR. Perf is not terrific. This PR causes recomputation of a few queries, and I had to insert workarounds.