Skip to main content

Module walk

Module walk 

Source
Expand description

Shape-only visitor API for deterministic traversal of Shape trees.

This module provides a visitor pattern for walking the static type structure described by Shape, emitting Path context at each node. It traverses only the type metadata — no values are inspected.

§Traversal order

  • Depth-first, declaration order. Struct fields are visited in the order they appear in the source. Enum variants are visited in declaration order, and within each variant, fields follow the same rule.
  • enter is called before children; leave is called after children (only if enter returned VisitDecision::Recurse).

§Traversal control

VisitDecision returned from ShapeVisitor::enter controls descent:

DecisionEffect
RecurseVisit children, then call leave.
SkipChildrenSkip descendants of this node; leave is still called.
StopTerminate the entire walk immediately.

§Cycle handling

Recursive types (e.g. a tree node whose children are Vec<Node>) would cause infinite descent. The walker tracks ancestor types by ConstTypeId and does not recurse into a type that is already on the current path. When a cycle is detected the node is still reported to enter/leave, but its children are skipped automatically — the visitor does not need to handle this.

Enums§

VisitDecision
Decision returned by ShapeVisitor::enter to control traversal.
WalkStatus
Outcome of walk_shape.

Traits§

ShapeVisitor
Visitor trait for shape-only traversal.

Functions§

walk_shape
Walk a Shape tree depth-first, calling visitor at each node.