-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ast::mut_visit::MutVisitor
and ast::visit::Visitor
do not have corresponding methods for all their methods
#127615
Comments
Make ast `MutVisitor` have the same method name and style as `Visitor` It doesn't map 100% because some `MutVisitor` methods can filter or even expand to multiple items, but consistency seems nicer. The last commit showcases how similar they are by changing ast validation to a `MutVisitor` (without actually doing any mutation yet). My plan is to replace all nodes that support it with error nodes if validation failed on them. This allows ast lowering to just assume things are error or valid, and avoids having to redo some checks, delaying bugs or checking the global error counter. tracking issue: rust-lang#127615
Make ast `MutVisitor` have the same method name and style as `Visitor` It doesn't map 100% because some `MutVisitor` methods can filter or even expand to multiple items, but consistency seems nicer. tracking issue: rust-lang#127615
…nkov Make ast `MutVisitor` have the same method name and style as `Visitor` It doesn't map 100% because some `MutVisitor` methods can filter or even expand to multiple items, but consistency seems nicer. tracking issue: rust-lang#127615
…nkov Make ast `MutVisitor` have the same method name and style as `Visitor` It doesn't map 100% because some `MutVisitor` methods can filter or even expand to multiple items, but consistency seems nicer. tracking issue: rust-lang#127615
Make ast `MutVisitor` have the same method name and style as `Visitor` It doesn't map 100% because some `MutVisitor` methods can filter or even expand to multiple items, but consistency seems nicer. tracking issue: rust-lang/rust#127615
Make ast `MutVisitor` have the same method name and style as `Visitor` It doesn't map 100% because some `MutVisitor` methods can filter or even expand to multiple items, but consistency seems nicer. tracking issue: rust-lang/rust#127615
All of these should be added, correct? |
For the ones that only exist in Visitor but not in MutVisitor, it may be useful to see if anyone actually overrides these and potentially entirely remove them. For the ones that only exist in MutVisitor but not Visitor, there are some that don't really make sense for Visitor, like the one for ids or the one for spans. There won't be any immutable visitors that just want to see all spans I think. So it seems ok to have such differences for leaf functions (where the Walker is a noop) |
Also sometimes MutVisitor has things like ItemKind visiting, but not Item... Looks like my idea was a bit naive. We basically need to analyze every missing method and see if there isn't one almost like it and if it can reasonably be refactored or if the mut visitor is just too different because of the mutation |
Someone can correct me if I'm wrong, but I don't think claiming this issue is entirely appropriate, as it involves tracking sub-issues. I for one would be wanting to pick the low hanging fruit for the 4th suggestion for example, but leave the others alone. |
I think I can begin to implement the macro that generates both traits and |
I did some digging and this is what I found out:
|
I was digging around to find out what to do with methods that have a |
There are implementors of MutVisitor that produce multiple items. E.g. when expanding a macro in item position, it may yield multiple items |
Ohhh, now I get it. Sorry, I didn't read the docs for SmallVec well enough. |
Is there a master list of what |
Hi @noahmbright! I didn't do it immediately as I think it deserves a bit more discussion. Sorry for not starting it until now. =/ I noticed that every type whose |
not entirely clear what is left to do, which easy issue is still left, and how can I claim it? |
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 aMutVisitor
requires extensive changes.Work items
visit_*
vswalk_*
naming schemeMutVisitor::visit_*
method a correspondingflat_map_*
method. E-mediumvisit_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.(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 correspondingVisitor
method and vice versa E-easywalk_
functions in one go, just like with the MIR visitors E-hardPrevious work
MutVisitor
have the same method name and style asVisitor
#127524The text was updated successfully, but these errors were encountered: