]>
git.proxmox.com Git - rustc.git/blob - compiler/rustc_middle/src/hir/nested_filter.rs
1 use rustc_hir
::intravisit
::nested_filter
::NestedFilter
;
3 /// Do not visit nested item-like things, but visit nested things
4 /// that are inside of an item-like.
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 */];`.
10 /// **This is the most common choice.** A very common pattern is
11 /// to use `deep_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.
14 pub struct OnlyBodies(());
15 impl<'hir
> NestedFilter
<'hir
> for OnlyBodies
{
16 type Map
= crate::hir
::map
::Map
<'hir
>;
17 const INTER
: bool
= false;
18 const INTRA
: bool
= true;
21 /// Visits all nested things, including item-likes.
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()`.
27 impl<'hir
> NestedFilter
<'hir
> for All
{
28 type Map
= crate::hir
::map
::Map
<'hir
>;
29 const INTER
: bool
= true;
30 const INTRA
: bool
= true;