@@ -426,10 +426,16 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
426
426
hir_visit:: walk_fn ( self , fk, fd, b, id)
427
427
}
428
428
429
- fn visit_use ( & mut self , p : & ' v hir:: UsePath < ' v > , hir_id : HirId ) {
429
+ fn visit_use ( & mut self , p : & ' v hir:: UsePath < ' v > , _hir_id : HirId ) {
430
430
// This is `visit_use`, but the type is `Path` so record it that way.
431
431
self . record ( "Path" , None , p) ;
432
- hir_visit:: walk_use ( self , p, hir_id)
432
+ // Don't call `hir_visit::walk_use(self, p, hir_id)`: it calls
433
+ // `visit_path` up to three times, once for each namespace result in
434
+ // `p.res`, by building temporary `Path`s that are not part of the real
435
+ // HIR, which causes `p` to be double- or triple-counted. Instead just
436
+ // walk the path internals (i.e. the segments) directly.
437
+ let hir:: Path { span : _, res : _, segments } = * p;
438
+ ast_visit:: walk_list!( self , visit_path_segment, segments) ;
433
439
}
434
440
435
441
fn visit_trait_item ( & mut self , ti : & ' v hir:: TraitItem < ' v > ) {
0 commit comments