Open
Description
In contrast to the MIR mut and immut visitors
rust/compiler/rustc_middle/src/mir/visit.rs
Lines 1235 to 1236 in c92a8e4
which are generated from a single macro, and are thus exactly the same except for mutation, the ast visitors are each handwritten. Their method naming scheme doesn't even match up, so changing from a Visitor
to a MutVisitor
requires extensive changes.
Work items
- Adjust names so everything has the
visit_*
vswalk_*
naming scheme - Give every
MutVisitor::visit_*
method a correspondingflat_map_*
method. E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate. - we can make it so implementors can override either
visit_foo
orflat_map_foo
without there being problems. Thewalk_bar
functions must invokeflat_map_foo
, so that they can pick up on more/fewer items being produced. Sowalk_flat_map_foo
(which only ever maps to a single output element) needs to invokevisit_foo
, notwalk_foo
. Otherwise overridingvisit_foo
will do nothing. - This should be using macros similar to what [WIP] Try optimizing noop AST mut visiting #127371 did, so you don't repeat yourself
- we can make it so implementors can override either
-
(Optional): move all thediscussed, should not be donewalk_
functions to defaulted methods on the trait (not sure this should be done, discuss on zulip first!) - Give every
MutVisitor::visit_*
method a correspondingVisitor
method and vice versa E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. - Create a macro that generates both visitors, including the
walk_
functions in one go, just like with the MIR visitors E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.