Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
derive-visitor
crate has a few shortcomings:Binder<SomeType>
.Ty::visit_inside
hack (a regular source of confusion).The last two points could be remedied by adding features to the upstream crate, but the first one requires a completely different approach. Over the last few weeks I came up with a new design for automatically-derived visitors, which I made into a crate over the winter break.
That crate centered around the main boilerplate required for building visitors, namely the code that calls
v.visit(self.field)
for each field of a type. A derive macro provides that boilerplate, and with that boilerplate out of the way it becomes easy to define flexible visitors. The crate provides more macros for that.This PR replaces all uses of
derive-visitor
with a custom visitor infrastructure based on my newderive-generic-visitor
crate. This adds aAstVisitable
trait implemented for all the types of the AST, as well as a pair ofVisitAst[Mut]
traits used to traverse such types. They provide a convenient overrideable interface to define visitors, of which you can see examples in this PR. Moreover we still support the extremely practical dynamic-dispatched-based API that we had withderive-visitors
.The second-to-last commit fixes #505.