Expand description
AST walker. Each overridden visit method has full control over what
happens with its node, it can do its own traversal of the node’s children,
call visit::walk_*
to apply the default traversal algorithm, or prevent
deeper traversal by doing nothing.
Note: it is an important invariant that the default visitor walks the body of a function in “execution order” (more concretely, reverse post-order with respect to the CFG implied by the AST), meaning that if AST node A may execute before AST node B, then A is visited first. The borrow checker in particular relies on this property.
Note: walking an AST before macro expansion is probably a bad idea. For instance, a walker looking for item names in a module will miss all of those that are created by the expansion of a macro.
Macros§
Enums§
Traits§
- Visitor
- Each method of the
Visitor
trait is a hook to be potentially overridden. Each method’s default implementation recursively visits the substructure of the input via the correspondingwalk
method; e.g., thevisit_item
method by default callsvisit::walk_item
. - Visitor
Result - Similar to the
Try
trait, but also implemented for()
. - Walk
Item Kind
Functions§
- walk_
anon_ const - walk_
arm - walk_
assoc_ item - walk_
assoc_ item_ constraint - walk_
attr_ args - walk_
attribute - walk_
block - walk_
closure_ binder - walk_
contract - walk_
crate - walk_
enum_ def - walk_
expr - walk_
expr_ field - walk_
field_ def - walk_fn
- walk_
fn_ decl - walk_
fn_ header - walk_
fn_ ret_ ty - walk_
format_ args - walk_
generic_ arg - walk_
generic_ args - walk_
generic_ param - walk_
generics - walk_
inline_ asm - walk_
inline_ asm_ sym - walk_
item - walk_
item_ 🔒ctxt - walk_
label - walk_
lifetime - walk_
local - walk_
mac - walk_
param - walk_
param_ bound - walk_
pat - walk_
pat_ field - walk_
path - walk_
path_ segment - walk_
poly_ trait_ ref - walk_
precise_ capturing_ arg - walk_
qself 🔒 - walk_
stmt - walk_
struct_ def - walk_
trait_ ref - walk_ty
- walk_
ty_ pat - walk_
use_ tree - walk_
variant - walk_
vis - walk_
where_ predicate - walk_
where_ predicate_ kind