Refactor HIR item-like traversal (part 1)

- 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
- add par_items(impl Fn(hir::ItemId)) to traverse all items in parallel

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
This commit is contained in:
Miguel Guarniz
2022-04-03 15:50:33 -04:00
parent 6a9080b25e
commit b73b4de982
6 changed files with 100 additions and 29 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`.