HIR/THIR visitors should deconstruct all values #141849
Labels
C-cleanup
Category: PRs that clean code up or issues documenting cleanup.
E-easy
Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Uh oh!
There was an error while loading. Please reload this page.
The AST visitor (in
compiler/rustc_ast/src/visit.rs
) uses struct/enum deconstruction to access fields in itswalk_*
methods, e.g.:This is good, because it's impossible to add a new field to an AST type and fail to update the appropriate visitor -- you'll get a compile error. (I swear there was a comment about this, but I can't find it right now.)
In contrast, the HIR visitor (in
compiler/rustc_hir/src/intravisit.rs
) uses field access:It would be good to change the HIR visitor to use deconstruction everywhere. This would identify any fields that are currently erroneously unvisited, and prevent future occurrences.
Likewise for the THIR visitor (in
compiler/rustc_middle/src/thir/visit.rs
) which is a lot smaller and simpler.This would be a good task for a new contributor, maybe even a good first bug.
The text was updated successfully, but these errors were encountered: