1
Fork 0

Move visit_id calls.

In `walk_item`, we call `visit_id` on every item kind. For most of them
we do it directly in `walk_item`. But for `ItemKind::Mod`,
`ItemKind::Enum`, and `ItemKind::Use` we instead do it in the `walk_*`
function called (via the `visit_*` function) from `walk_item`.

I can see no reason for this inconsistency, so this commit makes those
three cases like all the other cases, moving the `visit_id` calls into
`walk_item`. This also avoids the need for a few `HirId` arguments.
This commit is contained in:
Nicholas Nethercote 2025-03-07 17:02:33 +11:00
parent 98a48781fe
commit 872ac73f59
5 changed files with 14 additions and 21 deletions

View file

@ -255,9 +255,9 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
hir_visit::walk_body(self, b);
}
fn visit_mod(&mut self, m: &'v hir::Mod<'v>, _s: Span, n: HirId) {
fn visit_mod(&mut self, m: &'v hir::Mod<'v>, _s: Span, _n: HirId) {
self.record("Mod", None, m);
hir_visit::walk_mod(self, m, n)
hir_visit::walk_mod(self, m)
}
fn visit_foreign_item(&mut self, i: &'v hir::ForeignItem<'v>) {