3
3
// completely accurate (some things might be counted twice, others missed).
4
4
5
5
use rustc_ast:: visit:: BoundKind ;
6
- use rustc_ast:: { self as ast, AttrId , NodeId , visit as ast_visit} ;
6
+ use rustc_ast:: { self as ast, NodeId , visit as ast_visit} ;
7
7
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
8
8
use rustc_hir as hir;
9
9
use rustc_hir:: { HirId , intravisit as hir_visit} ;
@@ -13,13 +13,6 @@ use rustc_middle::util::common::to_readable_str;
13
13
use rustc_span:: Span ;
14
14
use rustc_span:: def_id:: LocalDefId ;
15
15
16
- #[ derive( Copy , Clone , PartialEq , Eq , Hash ) ]
17
- enum Id {
18
- Node ( HirId ) ,
19
- Attr ( AttrId ) ,
20
- None ,
21
- }
22
-
23
16
struct NodeStats {
24
17
count : usize ,
25
18
size : usize ,
@@ -62,7 +55,7 @@ impl Node {
62
55
struct StatCollector < ' k > {
63
56
krate : Option < Map < ' k > > ,
64
57
nodes : FxHashMap < & ' static str , Node > ,
65
- seen : FxHashSet < Id > ,
58
+ seen : FxHashSet < HirId > ,
66
59
}
67
60
68
61
pub fn print_hir_stats ( tcx : TyCtxt < ' _ > ) {
@@ -87,23 +80,29 @@ pub fn print_ast_stats(krate: &ast::Crate, title: &str, prefix: &str) {
87
80
88
81
impl < ' k > StatCollector < ' k > {
89
82
// Record a top-level node.
90
- fn record < T > ( & mut self , label : & ' static str , id : Id , val : & T ) {
83
+ fn record < T > ( & mut self , label : & ' static str , id : Option < HirId > , val : & T ) {
91
84
self . record_inner ( label, None , id, val) ;
92
85
}
93
86
94
87
// Record a two-level entry, with a top-level enum type and a variant.
95
- fn record_variant < T > ( & mut self , label1 : & ' static str , label2 : & ' static str , id : Id , val : & T ) {
88
+ fn record_variant < T > (
89
+ & mut self ,
90
+ label1 : & ' static str ,
91
+ label2 : & ' static str ,
92
+ id : Option < HirId > ,
93
+ val : & T ,
94
+ ) {
96
95
self . record_inner ( label1, Some ( label2) , id, val) ;
97
96
}
98
97
99
98
fn record_inner < T > (
100
99
& mut self ,
101
100
label1 : & ' static str ,
102
101
label2 : Option < & ' static str > ,
103
- id : Id ,
102
+ id : Option < HirId > ,
104
103
val : & T ,
105
104
) {
106
- if id != Id :: None && ! self . seen . insert ( id ) {
105
+ if id. is_some_and ( |x| ! self . seen . insert ( x ) ) {
107
106
return ;
108
107
}
109
108
@@ -191,7 +190,7 @@ macro_rules! record_variants {
191
190
192
191
impl < ' v > hir_visit:: Visitor < ' v > for StatCollector < ' v > {
193
192
fn visit_param ( & mut self , param : & ' v hir:: Param < ' v > ) {
194
- self . record ( "Param" , Id :: Node ( param. hir_id ) , param) ;
193
+ self . record ( "Param" , Some ( param. hir_id ) , param) ;
195
194
hir_visit:: walk_param ( self , param)
196
195
}
197
196
@@ -221,7 +220,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
221
220
}
222
221
223
222
fn visit_item ( & mut self , i : & ' v hir:: Item < ' v > ) {
224
- record_variants ! ( ( self , i, i. kind, Id :: Node ( i. hir_id( ) ) , hir, Item , ItemKind ) , [
223
+ record_variants ! ( ( self , i, i. kind, Some ( i. hir_id( ) ) , hir, Item , ItemKind ) , [
225
224
ExternCrate ,
226
225
Use ,
227
226
Static ,
@@ -243,47 +242,46 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
243
242
}
244
243
245
244
fn visit_body ( & mut self , b : & hir:: Body < ' v > ) {
246
- self . record ( "Body" , Id :: None , b) ;
245
+ self . record ( "Body" , None , b) ;
247
246
hir_visit:: walk_body ( self , b) ;
248
247
}
249
248
250
249
fn visit_mod ( & mut self , m : & ' v hir:: Mod < ' v > , _s : Span , n : HirId ) {
251
- self . record ( "Mod" , Id :: None , m) ;
250
+ self . record ( "Mod" , None , m) ;
252
251
hir_visit:: walk_mod ( self , m, n)
253
252
}
254
253
255
254
fn visit_foreign_item ( & mut self , i : & ' v hir:: ForeignItem < ' v > ) {
256
- record_variants ! (
257
- ( self , i, i. kind, Id :: Node ( i. hir_id( ) ) , hir, ForeignItem , ForeignItemKind ) ,
258
- [ Fn , Static , Type ]
259
- ) ;
255
+ record_variants ! ( ( self , i, i. kind, Some ( i. hir_id( ) ) , hir, ForeignItem , ForeignItemKind ) , [
256
+ Fn , Static , Type
257
+ ] ) ;
260
258
hir_visit:: walk_foreign_item ( self , i)
261
259
}
262
260
263
261
fn visit_local ( & mut self , l : & ' v hir:: LetStmt < ' v > ) {
264
- self . record ( "Local" , Id :: Node ( l. hir_id ) , l) ;
262
+ self . record ( "Local" , Some ( l. hir_id ) , l) ;
265
263
hir_visit:: walk_local ( self , l)
266
264
}
267
265
268
266
fn visit_block ( & mut self , b : & ' v hir:: Block < ' v > ) {
269
- self . record ( "Block" , Id :: Node ( b. hir_id ) , b) ;
267
+ self . record ( "Block" , Some ( b. hir_id ) , b) ;
270
268
hir_visit:: walk_block ( self , b)
271
269
}
272
270
273
271
fn visit_stmt ( & mut self , s : & ' v hir:: Stmt < ' v > ) {
274
- record_variants ! ( ( self , s, s. kind, Id :: Node ( s. hir_id) , hir, Stmt , StmtKind ) , [
272
+ record_variants ! ( ( self , s, s. kind, Some ( s. hir_id) , hir, Stmt , StmtKind ) , [
275
273
Let , Item , Expr , Semi
276
274
] ) ;
277
275
hir_visit:: walk_stmt ( self , s)
278
276
}
279
277
280
278
fn visit_arm ( & mut self , a : & ' v hir:: Arm < ' v > ) {
281
- self . record ( "Arm" , Id :: Node ( a. hir_id ) , a) ;
279
+ self . record ( "Arm" , Some ( a. hir_id ) , a) ;
282
280
hir_visit:: walk_arm ( self , a)
283
281
}
284
282
285
283
fn visit_pat ( & mut self , p : & ' v hir:: Pat < ' v > ) {
286
- record_variants ! ( ( self , p, p. kind, Id :: Node ( p. hir_id) , hir, Pat , PatKind ) , [
284
+ record_variants ! ( ( self , p, p. kind, Some ( p. hir_id) , hir, Pat , PatKind ) , [
287
285
Wild ,
288
286
Binding ,
289
287
Struct ,
@@ -304,12 +302,12 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
304
302
}
305
303
306
304
fn visit_pat_field ( & mut self , f : & ' v hir:: PatField < ' v > ) {
307
- self . record ( "PatField" , Id :: Node ( f. hir_id ) , f) ;
305
+ self . record ( "PatField" , Some ( f. hir_id ) , f) ;
308
306
hir_visit:: walk_pat_field ( self , f)
309
307
}
310
308
311
309
fn visit_expr ( & mut self , e : & ' v hir:: Expr < ' v > ) {
312
- record_variants ! ( ( self , e, e. kind, Id :: Node ( e. hir_id) , hir, Expr , ExprKind ) , [
310
+ record_variants ! ( ( self , e, e. kind, Some ( e. hir_id) , hir, Expr , ExprKind ) , [
313
311
ConstBlock , Array , Call , MethodCall , Tup , Binary , Unary , Lit , Cast , Type , DropTemps ,
314
312
Let , If , Loop , Match , Closure , Block , Assign , AssignOp , Field , Index , Path , AddrOf ,
315
313
Break , Continue , Ret , Become , InlineAsm , OffsetOf , Struct , Repeat , Yield , Err
@@ -318,12 +316,12 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
318
316
}
319
317
320
318
fn visit_expr_field ( & mut self , f : & ' v hir:: ExprField < ' v > ) {
321
- self . record ( "ExprField" , Id :: Node ( f. hir_id ) , f) ;
319
+ self . record ( "ExprField" , Some ( f. hir_id ) , f) ;
322
320
hir_visit:: walk_expr_field ( self , f)
323
321
}
324
322
325
323
fn visit_ty ( & mut self , t : & ' v hir:: Ty < ' v > ) {
326
- record_variants ! ( ( self , t, t. kind, Id :: Node ( t. hir_id) , hir, Ty , TyKind ) , [
324
+ record_variants ! ( ( self , t, t. kind, Some ( t. hir_id) , hir, Ty , TyKind ) , [
327
325
InferDelegation ,
328
326
Slice ,
329
327
Array ,
@@ -345,17 +343,17 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
345
343
}
346
344
347
345
fn visit_generic_param ( & mut self , p : & ' v hir:: GenericParam < ' v > ) {
348
- self . record ( "GenericParam" , Id :: Node ( p. hir_id ) , p) ;
346
+ self . record ( "GenericParam" , Some ( p. hir_id ) , p) ;
349
347
hir_visit:: walk_generic_param ( self , p)
350
348
}
351
349
352
350
fn visit_generics ( & mut self , g : & ' v hir:: Generics < ' v > ) {
353
- self . record ( "Generics" , Id :: None , g) ;
351
+ self . record ( "Generics" , None , g) ;
354
352
hir_visit:: walk_generics ( self , g)
355
353
}
356
354
357
355
fn visit_where_predicate ( & mut self , p : & ' v hir:: WherePredicate < ' v > ) {
358
- record_variants ! ( ( self , p, p, Id :: None , hir, WherePredicate , WherePredicate ) , [
356
+ record_variants ! ( ( self , p, p, None , hir, WherePredicate , WherePredicate ) , [
359
357
BoundPredicate ,
360
358
RegionPredicate ,
361
359
EqPredicate
@@ -371,66 +369,64 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
371
369
_: Span ,
372
370
id : LocalDefId ,
373
371
) {
374
- self . record ( "FnDecl" , Id :: None , fd) ;
372
+ self . record ( "FnDecl" , None , fd) ;
375
373
hir_visit:: walk_fn ( self , fk, fd, b, id)
376
374
}
377
375
378
376
fn visit_use ( & mut self , p : & ' v hir:: UsePath < ' v > , hir_id : HirId ) {
379
377
// This is `visit_use`, but the type is `Path` so record it that way.
380
- self . record ( "Path" , Id :: None , p) ;
378
+ self . record ( "Path" , None , p) ;
381
379
hir_visit:: walk_use ( self , p, hir_id)
382
380
}
383
381
384
382
fn visit_trait_item ( & mut self , ti : & ' v hir:: TraitItem < ' v > ) {
385
- record_variants ! (
386
- ( self , ti, ti. kind, Id :: Node ( ti. hir_id( ) ) , hir, TraitItem , TraitItemKind ) ,
387
- [ Const , Fn , Type ]
388
- ) ;
383
+ record_variants ! ( ( self , ti, ti. kind, Some ( ti. hir_id( ) ) , hir, TraitItem , TraitItemKind ) , [
384
+ Const , Fn , Type
385
+ ] ) ;
389
386
hir_visit:: walk_trait_item ( self , ti)
390
387
}
391
388
392
389
fn visit_trait_item_ref ( & mut self , ti : & ' v hir:: TraitItemRef ) {
393
- self . record ( "TraitItemRef" , Id :: Node ( ti. id . hir_id ( ) ) , ti) ;
390
+ self . record ( "TraitItemRef" , Some ( ti. id . hir_id ( ) ) , ti) ;
394
391
hir_visit:: walk_trait_item_ref ( self , ti)
395
392
}
396
393
397
394
fn visit_impl_item ( & mut self , ii : & ' v hir:: ImplItem < ' v > ) {
398
- record_variants ! (
399
- ( self , ii, ii. kind, Id :: Node ( ii. hir_id( ) ) , hir, ImplItem , ImplItemKind ) ,
400
- [ Const , Fn , Type ]
401
- ) ;
395
+ record_variants ! ( ( self , ii, ii. kind, Some ( ii. hir_id( ) ) , hir, ImplItem , ImplItemKind ) , [
396
+ Const , Fn , Type
397
+ ] ) ;
402
398
hir_visit:: walk_impl_item ( self , ii)
403
399
}
404
400
405
401
fn visit_foreign_item_ref ( & mut self , fi : & ' v hir:: ForeignItemRef ) {
406
- self . record ( "ForeignItemRef" , Id :: Node ( fi. id . hir_id ( ) ) , fi) ;
402
+ self . record ( "ForeignItemRef" , Some ( fi. id . hir_id ( ) ) , fi) ;
407
403
hir_visit:: walk_foreign_item_ref ( self , fi)
408
404
}
409
405
410
406
fn visit_impl_item_ref ( & mut self , ii : & ' v hir:: ImplItemRef ) {
411
- self . record ( "ImplItemRef" , Id :: Node ( ii. id . hir_id ( ) ) , ii) ;
407
+ self . record ( "ImplItemRef" , Some ( ii. id . hir_id ( ) ) , ii) ;
412
408
hir_visit:: walk_impl_item_ref ( self , ii)
413
409
}
414
410
415
411
fn visit_param_bound ( & mut self , b : & ' v hir:: GenericBound < ' v > ) {
416
- record_variants ! ( ( self , b, b, Id :: None , hir, GenericBound , GenericBound ) , [
412
+ record_variants ! ( ( self , b, b, None , hir, GenericBound , GenericBound ) , [
417
413
Trait , Outlives , Use
418
414
] ) ;
419
415
hir_visit:: walk_param_bound ( self , b)
420
416
}
421
417
422
418
fn visit_field_def ( & mut self , s : & ' v hir:: FieldDef < ' v > ) {
423
- self . record ( "FieldDef" , Id :: Node ( s. hir_id ) , s) ;
419
+ self . record ( "FieldDef" , Some ( s. hir_id ) , s) ;
424
420
hir_visit:: walk_field_def ( self , s)
425
421
}
426
422
427
423
fn visit_variant ( & mut self , v : & ' v hir:: Variant < ' v > ) {
428
- self . record ( "Variant" , Id :: None , v) ;
424
+ self . record ( "Variant" , None , v) ;
429
425
hir_visit:: walk_variant ( self , v)
430
426
}
431
427
432
428
fn visit_generic_arg ( & mut self , ga : & ' v hir:: GenericArg < ' v > ) {
433
- record_variants ! ( ( self , ga, ga, Id :: Node ( ga. hir_id( ) ) , hir, GenericArg , GenericArg ) , [
429
+ record_variants ! ( ( self , ga, ga, Some ( ga. hir_id( ) ) , hir, GenericArg , GenericArg ) , [
434
430
Lifetime , Type , Const , Infer
435
431
] ) ;
436
432
match ga {
@@ -442,50 +438,50 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
442
438
}
443
439
444
440
fn visit_lifetime ( & mut self , lifetime : & ' v hir:: Lifetime ) {
445
- self . record ( "Lifetime" , Id :: Node ( lifetime. hir_id ) , lifetime) ;
441
+ self . record ( "Lifetime" , Some ( lifetime. hir_id ) , lifetime) ;
446
442
hir_visit:: walk_lifetime ( self , lifetime)
447
443
}
448
444
449
445
fn visit_path ( & mut self , path : & hir:: Path < ' v > , _id : HirId ) {
450
- self . record ( "Path" , Id :: None , path) ;
446
+ self . record ( "Path" , None , path) ;
451
447
hir_visit:: walk_path ( self , path)
452
448
}
453
449
454
450
fn visit_path_segment ( & mut self , path_segment : & ' v hir:: PathSegment < ' v > ) {
455
- self . record ( "PathSegment" , Id :: None , path_segment) ;
451
+ self . record ( "PathSegment" , None , path_segment) ;
456
452
hir_visit:: walk_path_segment ( self , path_segment)
457
453
}
458
454
459
455
fn visit_generic_args ( & mut self , ga : & ' v hir:: GenericArgs < ' v > ) {
460
- self . record ( "GenericArgs" , Id :: None , ga) ;
456
+ self . record ( "GenericArgs" , None , ga) ;
461
457
hir_visit:: walk_generic_args ( self , ga)
462
458
}
463
459
464
460
fn visit_assoc_item_constraint ( & mut self , constraint : & ' v hir:: AssocItemConstraint < ' v > ) {
465
- self . record ( "AssocItemConstraint" , Id :: Node ( constraint. hir_id ) , constraint) ;
461
+ self . record ( "AssocItemConstraint" , Some ( constraint. hir_id ) , constraint) ;
466
462
hir_visit:: walk_assoc_item_constraint ( self , constraint)
467
463
}
468
464
469
465
fn visit_attribute ( & mut self , attr : & ' v ast:: Attribute ) {
470
- self . record ( "Attribute" , Id :: Attr ( attr . id ) , attr) ;
466
+ self . record ( "Attribute" , None , attr) ;
471
467
}
472
468
473
469
fn visit_inline_asm ( & mut self , asm : & ' v hir:: InlineAsm < ' v > , id : HirId ) {
474
- self . record ( "InlineAsm" , Id :: None , asm) ;
470
+ self . record ( "InlineAsm" , None , asm) ;
475
471
hir_visit:: walk_inline_asm ( self , asm, id) ;
476
472
}
477
473
}
478
474
479
475
impl < ' v > ast_visit:: Visitor < ' v > for StatCollector < ' v > {
480
476
fn visit_foreign_item ( & mut self , i : & ' v ast:: ForeignItem ) {
481
- record_variants ! ( ( self , i, i. kind, Id :: None , ast, ForeignItem , ForeignItemKind ) , [
477
+ record_variants ! ( ( self , i, i. kind, None , ast, ForeignItem , ForeignItemKind ) , [
482
478
Static , Fn , TyAlias , MacCall
483
479
] ) ;
484
480
ast_visit:: walk_item ( self , i)
485
481
}
486
482
487
483
fn visit_item ( & mut self , i : & ' v ast:: Item ) {
488
- record_variants ! ( ( self , i, i. kind, Id :: None , ast, Item , ItemKind ) , [
484
+ record_variants ! ( ( self , i, i. kind, None , ast, Item , ItemKind ) , [
489
485
ExternCrate ,
490
486
Use ,
491
487
Static ,
@@ -510,34 +506,34 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
510
506
}
511
507
512
508
fn visit_local ( & mut self , l : & ' v ast:: Local ) {
513
- self . record ( "Local" , Id :: None , l) ;
509
+ self . record ( "Local" , None , l) ;
514
510
ast_visit:: walk_local ( self , l)
515
511
}
516
512
517
513
fn visit_block ( & mut self , b : & ' v ast:: Block ) {
518
- self . record ( "Block" , Id :: None , b) ;
514
+ self . record ( "Block" , None , b) ;
519
515
ast_visit:: walk_block ( self , b)
520
516
}
521
517
522
518
fn visit_stmt ( & mut self , s : & ' v ast:: Stmt ) {
523
- record_variants ! ( ( self , s, s. kind, Id :: None , ast, Stmt , StmtKind ) , [
519
+ record_variants ! ( ( self , s, s. kind, None , ast, Stmt , StmtKind ) , [
524
520
Let , Item , Expr , Semi , Empty , MacCall
525
521
] ) ;
526
522
ast_visit:: walk_stmt ( self , s)
527
523
}
528
524
529
525
fn visit_param ( & mut self , p : & ' v ast:: Param ) {
530
- self . record ( "Param" , Id :: None , p) ;
526
+ self . record ( "Param" , None , p) ;
531
527
ast_visit:: walk_param ( self , p)
532
528
}
533
529
534
530
fn visit_arm ( & mut self , a : & ' v ast:: Arm ) {
535
- self . record ( "Arm" , Id :: None , a) ;
531
+ self . record ( "Arm" , None , a) ;
536
532
ast_visit:: walk_arm ( self , a)
537
533
}
538
534
539
535
fn visit_pat ( & mut self , p : & ' v ast:: Pat ) {
540
- record_variants ! ( ( self , p, p. kind, Id :: None , ast, Pat , PatKind ) , [
536
+ record_variants ! ( ( self , p, p. kind, None , ast, Pat , PatKind ) , [
541
537
Wild ,
542
538
Ident ,
543
539
Struct ,
@@ -563,7 +559,7 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
563
559
fn visit_expr ( & mut self , e : & ' v ast:: Expr ) {
564
560
#[ rustfmt:: skip]
565
561
record_variants ! (
566
- ( self , e, e. kind, Id :: None , ast, Expr , ExprKind ) ,
562
+ ( self , e, e. kind, None , ast, Expr , ExprKind ) ,
567
563
[
568
564
Array , ConstBlock , Call , MethodCall , Tup , Binary , Unary , Lit , Cast , Type , Let ,
569
565
If , While , ForLoop , Loop , Match , Closure , Block , Await , TryBlock , Assign ,
@@ -576,7 +572,7 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
576
572
}
577
573
578
574
fn visit_ty ( & mut self , t : & ' v ast:: Ty ) {
579
- record_variants ! ( ( self , t, t. kind, Id :: None , ast, Ty , TyKind ) , [
575
+ record_variants ! ( ( self , t, t. kind, None , ast, Ty , TyKind ) , [
580
576
Slice ,
581
577
Array ,
582
578
Ptr ,
@@ -603,12 +599,12 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
603
599
}
604
600
605
601
fn visit_generic_param ( & mut self , g : & ' v ast:: GenericParam ) {
606
- self . record ( "GenericParam" , Id :: None , g) ;
602
+ self . record ( "GenericParam" , None , g) ;
607
603
ast_visit:: walk_generic_param ( self , g)
608
604
}
609
605
610
606
fn visit_where_predicate ( & mut self , p : & ' v ast:: WherePredicate ) {
611
- record_variants ! ( ( self , p, p, Id :: None , ast, WherePredicate , WherePredicate ) , [
607
+ record_variants ! ( ( self , p, p, None , ast, WherePredicate , WherePredicate ) , [
612
608
BoundPredicate ,
613
609
RegionPredicate ,
614
610
EqPredicate
@@ -617,12 +613,12 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
617
613
}
618
614
619
615
fn visit_fn ( & mut self , fk : ast_visit:: FnKind < ' v > , _: Span , _: NodeId ) {
620
- self . record ( "FnDecl" , Id :: None , fk. decl ( ) ) ;
616
+ self . record ( "FnDecl" , None , fk. decl ( ) ) ;
621
617
ast_visit:: walk_fn ( self , fk)
622
618
}
623
619
624
620
fn visit_assoc_item ( & mut self , i : & ' v ast:: AssocItem , ctxt : ast_visit:: AssocCtxt ) {
625
- record_variants ! ( ( self , i, i. kind, Id :: None , ast, AssocItem , AssocItemKind ) , [
621
+ record_variants ! ( ( self , i, i. kind, None , ast, AssocItem , AssocItemKind ) , [
626
622
Const ,
627
623
Fn ,
628
624
Type ,
@@ -634,19 +630,19 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
634
630
}
635
631
636
632
fn visit_param_bound ( & mut self , b : & ' v ast:: GenericBound , _ctxt : BoundKind ) {
637
- record_variants ! ( ( self , b, b, Id :: None , ast, GenericBound , GenericBound ) , [
633
+ record_variants ! ( ( self , b, b, None , ast, GenericBound , GenericBound ) , [
638
634
Trait , Outlives , Use
639
635
] ) ;
640
636
ast_visit:: walk_param_bound ( self , b)
641
637
}
642
638
643
639
fn visit_field_def ( & mut self , s : & ' v ast:: FieldDef ) {
644
- self . record ( "FieldDef" , Id :: None , s) ;
640
+ self . record ( "FieldDef" , None , s) ;
645
641
ast_visit:: walk_field_def ( self , s)
646
642
}
647
643
648
644
fn visit_variant ( & mut self , v : & ' v ast:: Variant ) {
649
- self . record ( "Variant" , Id :: None , v) ;
645
+ self . record ( "Variant" , None , v) ;
650
646
ast_visit:: walk_variant ( self , v)
651
647
}
652
648
@@ -660,7 +656,7 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
660
656
// common than the former case, so we implement this visitor and tolerate
661
657
// the double counting in the former case.
662
658
fn visit_path_segment ( & mut self , path_segment : & ' v ast:: PathSegment ) {
663
- self . record ( "PathSegment" , Id :: None , path_segment) ;
659
+ self . record ( "PathSegment" , None , path_segment) ;
664
660
ast_visit:: walk_path_segment ( self , path_segment)
665
661
}
666
662
@@ -669,7 +665,7 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
669
665
// common, so we implement `visit_generic_args` and tolerate the double
670
666
// counting in the former case.
671
667
fn visit_generic_args ( & mut self , g : & ' v ast:: GenericArgs ) {
672
- record_variants ! ( ( self , g, g, Id :: None , ast, GenericArgs , GenericArgs ) , [
668
+ record_variants ! ( ( self , g, g, None , ast, GenericArgs , GenericArgs ) , [
673
669
AngleBracketed ,
674
670
Parenthesized ,
675
671
ParenthesizedElided
@@ -678,24 +674,24 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
678
674
}
679
675
680
676
fn visit_attribute ( & mut self , attr : & ' v ast:: Attribute ) {
681
- record_variants ! ( ( self , attr, attr. kind, Id :: None , ast, Attribute , AttrKind ) , [
677
+ record_variants ! ( ( self , attr, attr. kind, None , ast, Attribute , AttrKind ) , [
682
678
Normal , DocComment
683
679
] ) ;
684
680
ast_visit:: walk_attribute ( self , attr)
685
681
}
686
682
687
683
fn visit_expr_field ( & mut self , f : & ' v ast:: ExprField ) {
688
- self . record ( "ExprField" , Id :: None , f) ;
684
+ self . record ( "ExprField" , None , f) ;
689
685
ast_visit:: walk_expr_field ( self , f)
690
686
}
691
687
692
688
fn visit_crate ( & mut self , krate : & ' v ast:: Crate ) {
693
- self . record ( "Crate" , Id :: None , krate) ;
689
+ self . record ( "Crate" , None , krate) ;
694
690
ast_visit:: walk_crate ( self , krate)
695
691
}
696
692
697
693
fn visit_inline_asm ( & mut self , asm : & ' v ast:: InlineAsm ) {
698
- self . record ( "InlineAsm" , Id :: None , asm) ;
694
+ self . record ( "InlineAsm" , None , asm) ;
699
695
ast_visit:: walk_inline_asm ( self , asm)
700
696
}
701
697
}
0 commit comments