In contrast to the MIR mut and immut visitors
|
make_mir_visitor!(Visitor,); |
|
make_mir_visitor!(MutVisitor, mut); |
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
Previous work
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
Visitorto aMutVisitorrequires extensive changes.Work items
visit_*vswalk_*naming schemeMutVisitor::visit_*method a correspondingflat_map_*method. E-mediumvisit_fooorflat_map_foowithout there being problems. Thewalk_barfunctions 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_foowill do nothing.(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!)MutVisitor::visit_*method a correspondingVisitormethod and vice versa E-easywalk_functions in one go, just like with the MIR visitors E-hardPrevious work
MutVisitorhave the same method name and style asVisitor#127524MutVisitorandVisitorto dedup code #141249visit_clobberand moveDummyAstNodetorustc_expand#141430visit_mtfromast::mut_visit#141632WalkItemKindformut_visitandvisit#141635&mut P<T>in AST visitors #141636visit_idto astVisitor#141843check_id#142398&mut P<T>invisit_expretc methods #142371VisitorandMutVisitor#142706