[−][src]Module rustc_hir::intravisit

HIR walker for walking the contents of nodes.

For an overview of the visitor strategy, see the docs on the super::itemlikevisit::ItemLikeVisitor trait.

If you have decided to use this visitor, here are some general notes on how to do so:

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 intravisit::walk_* to apply the default traversal algorithm, or prevent deeper traversal by doing nothing.

When visiting the HIR, the contents of nested items are NOT visited by default. This is different from the AST visitor, which does a deep walk. Hence this module is called intravisit; see the method visit_nested_item for more details.

Note: it is an important invariant that the default visitor walks the body of a function in "execution order" - more concretely, if we consider the reverse post-order (RPO) of the CFG implied by the HIR, then a pre-order traversal of the HIR is consistent with the CFG RPO on the initial CFG point of each HIR node, while a post-order traversal of the HIR is consistent with the CFG RPO on each final CFG point of each CFG node.

One thing that follows is that if HIR node A always starts/ends executing before HIR node B, then A appears in traversal pre/postorder before B, respectively. (This follows from RPO respecting CFG domination).

This order consistency is required in a few places in rustc, for example generator inference, and possibly also HIR borrowck.

Structs

DeepVisitor
ErasedMap

An erased version of Map<'hir>, using dynamic dispatch. NOTE: This type is effectively only usable with NestedVisitorMap::None.

ParDeepVisitor

Enums

FnKind
NestedVisitorMap

Specifies what nested things a visitor wants to visit. The most common choice is OnlyBodies, which will cause the visitor to visit fn bodies for fns that it encounters, but skip over nested item-like things.

Traits

IntoVisitor
Map

An abstract representation of the HIR rustc_middle::hir::map::Map.

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_mod method by default calls intravisit::walk_mod.

Functions

walk_anon_const
walk_arm
walk_assoc_type_binding
walk_associated_item_kind
walk_block
walk_body
walk_crate

Walks the contents of a crate. See also Crate::visit_all_items.

walk_defaultness
walk_enum_def
walk_expr
walk_fn
walk_fn_decl
walk_fn_kind
walk_fn_ret_ty
walk_foreign_item
walk_generic_args
walk_generic_param
walk_generics
walk_ident
walk_impl_item
walk_impl_item_ref
walk_item
walk_label
walk_lifetime
walk_local
walk_macro_def
walk_mod
walk_param
walk_param_bound
walk_pat
walk_path
walk_path_segment
walk_poly_trait_ref
walk_qpath
walk_stmt
walk_struct_def
walk_struct_field
walk_trait_item
walk_trait_item_ref
walk_trait_ref
walk_ty
walk_use
walk_variant
walk_vis
walk_where_predicate