]>
Commit | Line | Data |
---|---|---|
5099ac24 FG |
1 | use 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. | |
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; | |
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()`. | |
26 | pub struct All(()); | |
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; | |
31 | } |