Module wrappers

Source
Expand description

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.

To use such a wrapper, just override the visit method of your visitor to call TheWrapper::new(self).visit(x). This will integrate the wrapper into the normal behavior of your visitor.

Each wrapper interacts with its wrapped visitor via a trait. To be able to use several wrappers at once, they must implement the wrapper-specific trait themselves and forward to their wrappee visitor. It’s a bit annoying as that potentially requires N^2 impls. I don’t know of a better design.

Structs§

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.
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§

VisitorWithBinderDepth
VisitorWithBinderStack
VisitorWithItem
VisitorWithItemMut
VisitorWithSpan