rust/compiler/rustc_middle
Matthias Krüger 076c047fe1
Rollup merge of #135314 - compiler-errors:eagerly-mono-closures, r=wesleywiser
Eagerly collect mono items for non-generic closures

This allows users to use `-Zprint-mono-items=eager` to eagerly monomorphize closures and coroutine bodies, in case they want to inspect the LLVM or ASM for those items.

`-Zprint-mono-items`, which used to be called `-Zprint-trans-items`, was originally added in https://github.com/rust-lang/rust/pull/30900:

> Eager mode is meant to be used in conjunction with incremental compilation
> where a stable set of translation items is more important than a minimal
> one. Thus, eager mode will instantiate drop-glue for every drop-able type
> in the crate, even of no drop call for that type exists (yet). It will
> also instantiate default implementations of trait methods, something that
> otherwise is only done on demand.

Although it remains an unstable option, its purpose has somewhat expanded since then, and as far as I can tell it's generally useful for cases when you want to monomorphize as many items as possible, even if they're unreachable. Specifically, it's useful for debugging since you can look at the codegen'd body of a function, since we don't emit items that are not reachable in monomorphization.

And even more specifically, it would be very to monomorphize the coroutine body of an async fn, since those you can't easily call those without a runtime. This PR enables this usecase since we now monomorphize `DefKind::Closure`.
2025-01-11 18:13:47 +01:00
..
src Rollup merge of #135314 - compiler-errors:eagerly-mono-closures, r=wesleywiser 2025-01-11 18:13:47 +01:00
Cargo.toml best_blame_constraint: prioritize blaming interesting-seeming constraints 2025-01-06 16:12:11 -08:00
messages.ftl Move some code from Compiler::enter to GlobalCtxt::finish 2024-11-09 17:55:39 +00:00
README.md

For more information about how rustc works, see the rustc dev guide.