Auto merge of #95655 - kckeiks:create-hir-crate-items-query, r=cjgillot

Refactor HIR item-like traversal (part 1)

Issue  #95004

- Create hir_crate_items query which traverses tcx.hir_crate(()).owners to return a hir::ModuleItems
- use tcx.hir_crate_items in tcx.hir().items() to return an iterator of hir::ItemId
- use tcx.hir_crate_items to introduce a tcx.hir().par_items(impl Fn(hir::ItemId)) to traverse all items in parallel;

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>

cc `@cjgillot`
This commit is contained in:
bors 2022-04-17 08:06:53 +00:00
commit edba282770
18 changed files with 435 additions and 422 deletions

View file

@ -45,6 +45,13 @@ rustc_queries! {
desc { "get the crate HIR" }
}
/// All items in the crate.
query hir_crate_items(_: ()) -> rustc_middle::hir::ModuleItems {
storage(ArenaCacheSelector<'tcx>)
eval_always
desc { "get HIR crate items" }
}
/// The items in a module.
///
/// This can be conveniently accessed by `tcx.hir().visit_item_likes_in_module`.