Module visit

Source
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§

try_visit
visit_opt
walk_list
walk_visitable_list

Enums§

AssocCtxt
BoundKind
FnCtxt
FnKind
LifetimeCtxt

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 corresponding walk method; e.g., the visit_item method by default calls visit::walk_item.
VisitorResult
Similar to the Try trait, but also implemented for ().
WalkItemKind

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