Gather body owners in hir_module_items
and hir_crate_items
#96341
Labels
E-easy
Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
E-help-wanted
Call for participation: Help is requested to fix this issue.
E-mentor
Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
Functions, constants and statics have an associated
hir::Body
and are known as body owners. Typechecking and MIR generation work by iterating over all the body owners in the crate. This iteration traverses the full HIR.The objective is to avoid repeated traversal of the full HIR by reusing the traversal done by
hir_module_items
andhir_crate_items
query. The secondary objective is to reduce the number of queries that directly depend on the full HIR query (hir_crate
).Instructions:
body_owners: Box<[LocalDefId]>
field inrustc_middle::hir::ModuleItems
;body_owners
in the two queries' visitors;hir_crate_items(()).body_owners
intcx.hir().{,par_}body_owners
instead of iterating ontcx.hir().krate()
.The following steps are a possible cleanup to avoid a few back-and-forth conversions between
LocalDefId
andHirId
:tcx.hir().{,maybe_}body_owned_by
to take aLocalDefId
as a parameter;tcx.hir().enclosing_body_owner
to return aLocalDefId
.The text was updated successfully, but these errors were encountered: