]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_middle/src/hir/nested_filter.rs
New upstream version 1.61.0+dfsg1
[rustc.git] / compiler / rustc_middle / src / hir / nested_filter.rs
CommitLineData
5099ac24
FG
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///
ee023bcb
FG
6/// Notably, possible occurrences of bodies in non-item-like things
7/// include: closures/generators, inline `const {}` blocks, and
8/// constant arguments of types, e.g. in `let _: [(); /* HERE */];`.
9///
5099ac24
FG
10/// **This is the most common choice.** A very common pattern is
11/// to use `visit_all_item_likes()` 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}