Expand description
Defines two overrideable visitor traits that can be used to conveniently traverse the whole contents of an item. This is useful when e.g. dealing with types, which show up pretty much everywhere in the ast.
The crate defines two traits:
Modules§
- wrappers đŸ”’
- This module defines a bunch of visitor wrappers, in the model described in the
derive_generic_visitor
crate. Each such wrapper is a non-recursive visitor; the only thing it does is that its.visit()
method calls into the appropriatevisit_foo
of the wrapper, then continues visiting with the wrapped visitor.
Structs§
- AstVisitable
Wrapper - Implementation detail: wrapper that implements
Visit[Mut]<T>
forT: #trait_name
, and delegates all the visiting to our trait’sdrive[_mut]
. Used in the implementation ofvisit_inner
- Body
Visitable Wrapper - Implementation detail: wrapper that implements
Visit[Mut]<T>
forT: #trait_name
, and delegates all the visiting to our trait’sdrive[_mut]
. Used in the implementation ofvisit_inner
- Dont
Leak Impl Details - Struct that we use to be able to use our visitor wrappers with each other to share
functionality, while still making the wrappers composable. We can implement e.g.
VisitorWithItem for DontLeakImplDetails<Wrapper<V>>
while still retaining the capacity to implementimpl<V: VisitorWithItem> VisitorWithItem for Wrapper<V>
that forwards to the inner visitor. - DynVisitor
- Ast and body visitor that uses dynamic dispatch to call the provided function on the visited values of the right type.
- Visit
With Binder Depth - Visitor wrapper that tracks the depth of binders. To use it, make a visitor that implements
VisitorWithBinderDepth
and override itsvisit
function as follows: - Visit
With Binder Stack - Visitor wrapper that tracks the stack of binders seen so far. See
VisitWithBinderDepth
for how to use. - Visit
With Item - Visitor wrapper that adds item-generic
enter_item
andexit_item
methods. - Visit
With Span - Visitor wrapper that tracks the current span. See
VisitWithBinderDepth
for how to use.
Traits§
- AstVisitable
- An overrideable visitor trait that can be used to conveniently traverse the whole contents of an item. This is useful when e.g. dealing with types, which show up pretty much everywhere in the ast.
- Body
Visitable - A smaller visitor group just for function bodies. This explores statements, places and operands, but does not recurse into types.
- Visit
Ast - Visit
AstMut - Visit
Body - Visit
Body Mut - Visitor
With Binder Depth - Visitor
With Binder Stack - Visitor
With Item - Visitor
With Item Mut - Visitor
With Span