HIR walker for walking the contents of nodes.
For an overview of the visitor strategy, see the docs on the
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,
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
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.
An erased version of
Map<'hir>, using dynamic dispatch.
NOTE: This type is effectively only usable with
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
An abstract representation of the HIR
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
visit_mod method by default calls
Walks the contents of a crate. See also