rustc_middle/hir/
nested_filter.rs

1use rustc_hir::intravisit::nested_filter::NestedFilter;
2
3/// Do not visit nested item-like things, but visit nested things
4/// that are inside of an item-like.
5///
6/// Notably, possible occurrences of bodies in non-item-like things
7/// include: closures/coroutines, inline `const {}` blocks, and
8/// constant arguments of types, e.g. in `let _: [(); /* HERE */];`.
9///
10/// **This is the most common choice.** A very common pattern is
11/// to use `visit_all_item_likes_in_crate()` as an outer loop,
12/// and to have the visitor that visits the contents of each item
13/// using this setting.
14pub struct OnlyBodies(());
15impl<'hir> NestedFilter<'hir> for OnlyBodies {
16    type Map = crate::hir::map::Map<'hir>;
17    const INTER: bool = false;
18    const INTRA: bool = true;
19}
20
21/// Visits all nested things, including item-likes.
22///
23/// **This is an unusual choice.** It is used when you want to
24/// process everything within their lexical context. Typically you
25/// kick off the visit by doing `walk_krate()`.
26pub struct All(());
27impl<'hir> NestedFilter<'hir> for All {
28    type Map = crate::hir::map::Map<'hir>;
29    const INTER: bool = true;
30    const INTRA: bool = true;
31}