Cache whether a body has inline consts

This commit is contained in:
Oli Scherer 2024-05-24 09:53:20 +00:00
parent ddc5f9b6c1
commit eae5031ecb
6 changed files with 21 additions and 4 deletions

View file

@ -225,7 +225,10 @@ fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LocalDefId> {
// Inline consts' bodies are created in
// typeck instead of during ast lowering, like all other bodies so far.
for def_id in tcx.hir().body_owners() {
set.extend(tcx.typeck(def_id).inline_consts.values())
// Incremental performance optimization: only load typeck results for things that actually have inline consts
if tcx.hir_owner_nodes(tcx.hir().body_owned_by(def_id).hir_id.owner).has_inline_consts {
set.extend(tcx.typeck(def_id).inline_consts.values())
}
}
// Additionally, tuple struct/variant constructors have MIR, but