code cleanup: if visit::walk_foo(a, b, c) discards b, then b should not be in its API. #14134
Labels
E-easy
Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
The pattern for our
syntax::visit
module is that each visit method has a default implementation that just walks the substructure of that node in the AST.What I often do when implementing a visitor is cut-and-paste the trait definition (with its default methods) into my new visitor and then consider each method to determine whether it should (1.) do extra-work, and/or (2.) stop the traversal, or (3.) just use the default impl.
When I see something like:
I might assume: "Ah, the walk routine is already going to look at
i
andg
, so if I need to look at those in my own code, then I can just inherit the visitor's default method."The problem with that assumption is this:
My proposal solution: Any
fn walk_foo
in visit.rs should not have any parameters that are ignored.The text was updated successfully, but these errors were encountered: