add visit_all_bodies_in_krate
helper
This commit is contained in:
parent
b3a482ca9b
commit
d885e4ce9d
3 changed files with 22 additions and 0 deletions
|
@ -25,5 +25,6 @@ pub use self::dep_node::WorkProductId;
|
||||||
pub use self::graph::DepGraph;
|
pub use self::graph::DepGraph;
|
||||||
pub use self::graph::WorkProduct;
|
pub use self::graph::WorkProduct;
|
||||||
pub use self::query::DepGraphQuery;
|
pub use self::query::DepGraphQuery;
|
||||||
|
pub use self::visit::visit_all_bodies_in_krate;
|
||||||
pub use self::visit::visit_all_item_likes_in_krate;
|
pub use self::visit::visit_all_item_likes_in_krate;
|
||||||
pub use self::raii::DepTask;
|
pub use self::raii::DepTask;
|
||||||
|
|
|
@ -74,3 +74,13 @@ pub fn visit_all_item_likes_in_krate<'a, 'tcx, V, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>
|
||||||
};
|
};
|
||||||
krate.visit_all_item_likes(&mut tracking_visitor)
|
krate.visit_all_item_likes(&mut tracking_visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn visit_all_bodies_in_krate<'a, 'tcx, C>(tcx: TyCtxt<'a, 'tcx, 'tcx>, callback: C)
|
||||||
|
where C: Fn(/* body_owner */ DefId, /* body id */ hir::BodyId),
|
||||||
|
{
|
||||||
|
let krate = tcx.hir.krate();
|
||||||
|
for body_id in krate.bodies.keys().cloned() {
|
||||||
|
let body_owner_def_id = tcx.hir.body_owner_def_id(body_id);
|
||||||
|
callback(body_owner_def_id, body_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2613,6 +2613,17 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
dep_graph::visit_all_item_likes_in_krate(self.global_tcx(), dep_node_fn, visitor);
|
dep_graph::visit_all_item_likes_in_krate(self.global_tcx(), dep_node_fn, visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Invokes `callback` for each body in the krate. This will
|
||||||
|
/// create a read edge from `DepNode::Krate` to the current task;
|
||||||
|
/// it is meant to be run in the context of some global task like
|
||||||
|
/// `BorrowckCrate`. The callback would then create a task like
|
||||||
|
/// `BorrowckBody(DefId)` to process each individual item.
|
||||||
|
pub fn visit_all_bodies_in_krate<C>(self, callback: C)
|
||||||
|
where C: Fn(/* body_owner */ DefId, /* body id */ hir::BodyId),
|
||||||
|
{
|
||||||
|
dep_graph::visit_all_bodies_in_krate(self.global_tcx(), callback)
|
||||||
|
}
|
||||||
|
|
||||||
/// Looks up the span of `impl_did` if the impl is local; otherwise returns `Err`
|
/// Looks up the span of `impl_did` if the impl is local; otherwise returns `Err`
|
||||||
/// with the name of the crate containing the impl.
|
/// with the name of the crate containing the impl.
|
||||||
pub fn span_of_impl(self, impl_did: DefId) -> Result<Span, Symbol> {
|
pub fn span_of_impl(self, impl_did: DefId) -> Result<Span, Symbol> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue