Module visitor

Source
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 appropriate visit_foo of the wrapper, then continues visiting with the wrapped visitor.

Structs§

AstVisitableWrapper
Implementation detail: wrapper that implements Visit[Mut]<T> for T: #trait_name, and delegates all the visiting to our trait’s drive[_mut]. Used in the implementation of visit_inner
BodyVisitableWrapper
Implementation detail: wrapper that implements Visit[Mut]<T> for T: #trait_name, and delegates all the visiting to our trait’s drive[_mut]. Used in the implementation of visit_inner
DontLeakImplDetails
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 implement impl<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.
VisitWithBinderDepth
Visitor wrapper that tracks the depth of binders. To use it, make a visitor that implements VisitorWithBinderDepth and override its visit function as follows:
VisitWithBinderStack
Visitor wrapper that tracks the stack of binders seen so far. See VisitWithBinderDepth for how to use.
VisitWithItem
Visitor wrapper that adds item-generic enter_item and exit_item methods.
VisitWithSpan
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.
BodyVisitable
A smaller visitor group just for function bodies. This explores statements, places and operands, but does not recurse into types.
VisitAst
VisitAstMut
VisitBody
VisitBodyMut
VisitorWithBinderDepth
VisitorWithBinderStack
VisitorWithItem
VisitorWithItemMut
VisitorWithSpan