1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use rustc_hir::intravisit::nested_filter::NestedFilter;

/// Do not visit nested item-like things, but visit nested things
/// that are inside of an item-like.
///
/// Notably, possible occurrences of bodies in non-item-like things
/// include: closures/generators, inline `const {}` blocks, and
/// constant arguments of types, e.g. in `let _: [(); /* HERE */];`.
///
/// **This is the most common choice.** A very common pattern is
/// to use `visit_all_item_likes_in_crate()` as an outer loop,
/// and to have the visitor that visits the contents of each item
/// using this setting.
pub struct OnlyBodies(());
impl<'hir> NestedFilter<'hir> for OnlyBodies {
    type Map = crate::hir::map::Map<'hir>;
    const INTER: bool = false;
    const INTRA: bool = true;
}

/// Visits all nested things, including item-likes.
///
/// **This is an unusual choice.** It is used when you want to
/// process everything within their lexical context. Typically you
/// kick off the visit by doing `walk_krate()`.
pub struct All(());
impl<'hir> NestedFilter<'hir> for All {
    type Map = crate::hir::map::Map<'hir>;
    const INTER: bool = true;
    const INTRA: bool = true;
}