@@ -104,8 +104,16 @@ pub trait MutVisitor: Sized {
104
104
walk_use_tree ( self , use_tree) ;
105
105
}
106
106
107
+ fn visit_foreign_item ( & mut self , ni : & mut P < ForeignItem > ) {
108
+ walk_item ( self , ni) ;
109
+ }
110
+
107
111
fn flat_map_foreign_item ( & mut self , ni : P < ForeignItem > ) -> SmallVec < [ P < ForeignItem > ; 1 ] > {
108
- walk_flat_map_item ( self , ni)
112
+ walk_flat_map_foreign_item ( self , ni)
113
+ }
114
+
115
+ fn visit_item ( & mut self , i : & mut P < Item > ) {
116
+ walk_item ( self , i) ;
109
117
}
110
118
111
119
fn flat_map_item ( & mut self , i : P < Item > ) -> SmallVec < [ P < Item > ; 1 ] > {
@@ -116,10 +124,18 @@ pub trait MutVisitor: Sized {
116
124
walk_fn_header ( self , header) ;
117
125
}
118
126
127
+ fn visit_field_def ( & mut self , fd : & mut FieldDef ) {
128
+ walk_field_def ( self , fd) ;
129
+ }
130
+
119
131
fn flat_map_field_def ( & mut self , fd : FieldDef ) -> SmallVec < [ FieldDef ; 1 ] > {
120
132
walk_flat_map_field_def ( self , fd)
121
133
}
122
134
135
+ fn visit_assoc_item ( & mut self , i : & mut P < AssocItem > , ctxt : AssocCtxt ) {
136
+ walk_assoc_item ( self , i, ctxt)
137
+ }
138
+
123
139
fn flat_map_assoc_item (
124
140
& mut self ,
125
141
i : P < AssocItem > ,
@@ -153,6 +169,10 @@ pub trait MutVisitor: Sized {
153
169
walk_flat_map_stmt ( self , s)
154
170
}
155
171
172
+ fn visit_arm ( & mut self , arm : & mut Arm ) {
173
+ walk_arm ( self , arm) ;
174
+ }
175
+
156
176
fn flat_map_arm ( & mut self , arm : Arm ) -> SmallVec < [ Arm ; 1 ] > {
157
177
walk_flat_map_arm ( self , arm)
158
178
}
@@ -199,6 +219,10 @@ pub trait MutVisitor: Sized {
199
219
walk_foreign_mod ( self , nm) ;
200
220
}
201
221
222
+ fn visit_variant ( & mut self , v : & mut Variant ) {
223
+ walk_variant ( self , v) ;
224
+ }
225
+
202
226
fn flat_map_variant ( & mut self , v : Variant ) -> SmallVec < [ Variant ; 1 ] > {
203
227
walk_flat_map_variant ( self , v)
204
228
}
@@ -251,6 +275,10 @@ pub trait MutVisitor: Sized {
251
275
walk_attribute ( self , at) ;
252
276
}
253
277
278
+ fn visit_param ( & mut self , param : & mut Param ) {
279
+ walk_param ( self , param) ;
280
+ }
281
+
254
282
fn flat_map_param ( & mut self , param : Param ) -> SmallVec < [ Param ; 1 ] > {
255
283
walk_flat_map_param ( self , param)
256
284
}
@@ -271,6 +299,10 @@ pub trait MutVisitor: Sized {
271
299
walk_variant_data ( self , vdata) ;
272
300
}
273
301
302
+ fn visit_generic_param ( & mut self , param : & mut GenericParam ) {
303
+ walk_generic_param ( self , param)
304
+ }
305
+
274
306
fn flat_map_generic_param ( & mut self , param : GenericParam ) -> SmallVec < [ GenericParam ; 1 ] > {
275
307
walk_flat_map_generic_param ( self , param)
276
308
}
@@ -287,6 +319,10 @@ pub trait MutVisitor: Sized {
287
319
walk_mt ( self , mt) ;
288
320
}
289
321
322
+ fn visit_expr_field ( & mut self , f : & mut ExprField ) {
323
+ walk_expr_field ( self , f) ;
324
+ }
325
+
290
326
fn flat_map_expr_field ( & mut self , f : ExprField ) -> SmallVec < [ ExprField ; 1 ] > {
291
327
walk_flat_map_expr_field ( self , f)
292
328
}
@@ -311,6 +347,10 @@ pub trait MutVisitor: Sized {
311
347
// Do nothing.
312
348
}
313
349
350
+ fn visit_pat_field ( & mut self , fp : & mut PatField ) {
351
+ walk_pat_field ( self , fp)
352
+ }
353
+
314
354
fn flat_map_pat_field ( & mut self , fp : PatField ) -> SmallVec < [ PatField ; 1 ] > {
315
355
walk_flat_map_pat_field ( self , fp)
316
356
}
@@ -429,16 +469,20 @@ pub fn visit_delim_span<T: MutVisitor>(vis: &mut T, DelimSpan { open, close }: &
429
469
vis. visit_span ( close) ;
430
470
}
431
471
432
- pub fn walk_flat_map_pat_field < T : MutVisitor > (
433
- vis : & mut T ,
434
- mut fp : PatField ,
435
- ) -> SmallVec < [ PatField ; 1 ] > {
436
- let PatField { attrs, id, ident, is_placeholder : _, is_shorthand : _, pat, span } = & mut fp;
472
+ pub fn walk_pat_field < T : MutVisitor > ( vis : & mut T , fp : & mut PatField ) {
473
+ let PatField { attrs, id, ident, is_placeholder : _, is_shorthand : _, pat, span } = fp;
437
474
vis. visit_id ( id) ;
438
475
visit_attrs ( vis, attrs) ;
439
476
vis. visit_ident ( ident) ;
440
477
vis. visit_pat ( pat) ;
441
478
vis. visit_span ( span) ;
479
+ }
480
+
481
+ pub fn walk_flat_map_pat_field < T : MutVisitor > (
482
+ vis : & mut T ,
483
+ mut fp : PatField ,
484
+ ) -> SmallVec < [ PatField ; 1 ] > {
485
+ vis. visit_pat_field ( & mut fp) ;
442
486
smallvec ! [ fp]
443
487
}
444
488
@@ -459,14 +503,18 @@ fn walk_use_tree<T: MutVisitor>(vis: &mut T, use_tree: &mut UseTree) {
459
503
vis. visit_span ( span) ;
460
504
}
461
505
462
- pub fn walk_flat_map_arm < T : MutVisitor > ( vis : & mut T , mut arm : Arm ) -> SmallVec < [ Arm ; 1 ] > {
463
- let Arm { attrs, pat, guard, body, span, id, is_placeholder : _ } = & mut arm;
506
+ pub fn walk_arm < T : MutVisitor > ( vis : & mut T , arm : & mut Arm ) {
507
+ let Arm { attrs, pat, guard, body, span, id, is_placeholder : _ } = arm;
464
508
vis. visit_id ( id) ;
465
509
visit_attrs ( vis, attrs) ;
466
510
vis. visit_pat ( pat) ;
467
511
visit_opt ( guard, |guard| vis. visit_expr ( guard) ) ;
468
512
visit_opt ( body, |body| vis. visit_expr ( body) ) ;
469
513
vis. visit_span ( span) ;
514
+ }
515
+
516
+ pub fn walk_flat_map_arm < T : MutVisitor > ( vis : & mut T , mut arm : Arm ) -> SmallVec < [ Arm ; 1 ] > {
517
+ vis. visit_arm ( & mut arm) ;
470
518
smallvec ! [ arm]
471
519
}
472
520
@@ -543,18 +591,22 @@ fn walk_foreign_mod<T: MutVisitor>(vis: &mut T, foreign_mod: &mut ForeignMod) {
543
591
items. flat_map_in_place ( |item| vis. flat_map_foreign_item ( item) ) ;
544
592
}
545
593
546
- pub fn walk_flat_map_variant < T : MutVisitor > (
547
- visitor : & mut T ,
548
- mut variant : Variant ,
549
- ) -> SmallVec < [ Variant ; 1 ] > {
550
- let Variant { ident, vis, attrs, id, data, disr_expr, span, is_placeholder : _ } = & mut variant;
594
+ pub fn walk_variant < T : MutVisitor > ( visitor : & mut T , variant : & mut Variant ) {
595
+ let Variant { ident, vis, attrs, id, data, disr_expr, span, is_placeholder : _ } = variant;
551
596
visitor. visit_id ( id) ;
552
597
visit_attrs ( visitor, attrs) ;
553
598
visitor. visit_vis ( vis) ;
554
599
visitor. visit_ident ( ident) ;
555
600
visitor. visit_variant_data ( data) ;
556
601
visit_opt ( disr_expr, |disr_expr| visitor. visit_anon_const ( disr_expr) ) ;
557
602
visitor. visit_span ( span) ;
603
+ }
604
+
605
+ pub fn walk_flat_map_variant < T : MutVisitor > (
606
+ vis : & mut T ,
607
+ mut variant : Variant ,
608
+ ) -> SmallVec < [ Variant ; 1 ] > {
609
+ vis. visit_variant ( & mut variant) ;
558
610
smallvec ! [ variant]
559
611
}
560
612
@@ -685,13 +737,17 @@ fn walk_meta_item<T: MutVisitor>(vis: &mut T, mi: &mut MetaItem) {
685
737
vis. visit_span ( span) ;
686
738
}
687
739
688
- pub fn walk_flat_map_param < T : MutVisitor > ( vis : & mut T , mut param : Param ) -> SmallVec < [ Param ; 1 ] > {
689
- let Param { attrs, id, pat, span, ty, is_placeholder : _ } = & mut param;
740
+ pub fn walk_param < T : MutVisitor > ( vis : & mut T , param : & mut Param ) {
741
+ let Param { attrs, id, pat, span, ty, is_placeholder : _ } = param;
690
742
vis. visit_id ( id) ;
691
743
visit_attrs ( vis, attrs) ;
692
744
vis. visit_pat ( pat) ;
693
745
vis. visit_ty ( ty) ;
694
746
vis. visit_span ( span) ;
747
+ }
748
+
749
+ pub fn walk_flat_map_param < T : MutVisitor > ( vis : & mut T , mut param : Param ) -> SmallVec < [ Param ; 1 ] > {
750
+ vis. visit_param ( & mut param) ;
695
751
smallvec ! [ param]
696
752
}
697
753
@@ -950,11 +1006,8 @@ fn walk_precise_capturing_arg<T: MutVisitor>(vis: &mut T, arg: &mut PreciseCaptu
950
1006
}
951
1007
}
952
1008
953
- pub fn walk_flat_map_generic_param < T : MutVisitor > (
954
- vis : & mut T ,
955
- mut param : GenericParam ,
956
- ) -> SmallVec < [ GenericParam ; 1 ] > {
957
- let GenericParam { id, ident, attrs, bounds, kind, colon_span, is_placeholder : _ } = & mut param;
1009
+ pub fn walk_generic_param < T : MutVisitor > ( vis : & mut T , param : & mut GenericParam ) {
1010
+ let GenericParam { id, ident, attrs, bounds, kind, colon_span, is_placeholder : _ } = param;
958
1011
vis. visit_id ( id) ;
959
1012
visit_attrs ( vis, attrs) ;
960
1013
vis. visit_ident ( ident) ;
@@ -972,6 +1025,13 @@ pub fn walk_flat_map_generic_param<T: MutVisitor>(
972
1025
if let Some ( colon_span) = colon_span {
973
1026
vis. visit_span ( colon_span) ;
974
1027
}
1028
+ }
1029
+
1030
+ pub fn walk_flat_map_generic_param < T : MutVisitor > (
1031
+ vis : & mut T ,
1032
+ mut param : GenericParam ,
1033
+ ) -> SmallVec < [ GenericParam ; 1 ] > {
1034
+ vis. visit_generic_param ( & mut param) ;
975
1035
smallvec ! [ param]
976
1036
}
977
1037
@@ -1054,30 +1114,38 @@ fn walk_poly_trait_ref<T: MutVisitor>(vis: &mut T, p: &mut PolyTraitRef) {
1054
1114
vis. visit_span ( span) ;
1055
1115
}
1056
1116
1057
- pub fn walk_flat_map_field_def < T : MutVisitor > (
1058
- visitor : & mut T ,
1059
- mut fd : FieldDef ,
1060
- ) -> SmallVec < [ FieldDef ; 1 ] > {
1061
- let FieldDef { span, ident, vis, id, ty, attrs, is_placeholder : _ } = & mut fd;
1117
+ pub fn walk_field_def < T : MutVisitor > ( visitor : & mut T , fd : & mut FieldDef ) {
1118
+ let FieldDef { span, ident, vis, id, ty, attrs, is_placeholder : _ } = fd;
1062
1119
visitor. visit_id ( id) ;
1063
1120
visit_attrs ( visitor, attrs) ;
1064
1121
visitor. visit_vis ( vis) ;
1065
1122
visit_opt ( ident, |ident| visitor. visit_ident ( ident) ) ;
1066
1123
visitor. visit_ty ( ty) ;
1067
1124
visitor. visit_span ( span) ;
1068
- smallvec ! [ fd]
1069
1125
}
1070
1126
1071
- pub fn walk_flat_map_expr_field < T : MutVisitor > (
1127
+ pub fn walk_flat_map_field_def < T : MutVisitor > (
1072
1128
vis : & mut T ,
1073
- mut f : ExprField ,
1074
- ) -> SmallVec < [ ExprField ; 1 ] > {
1075
- let ExprField { ident, expr, span, is_shorthand : _, attrs, id, is_placeholder : _ } = & mut f;
1129
+ mut fd : FieldDef ,
1130
+ ) -> SmallVec < [ FieldDef ; 1 ] > {
1131
+ vis. visit_field_def ( & mut fd) ;
1132
+ smallvec ! [ fd]
1133
+ }
1134
+
1135
+ pub fn walk_expr_field < T : MutVisitor > ( vis : & mut T , f : & mut ExprField ) {
1136
+ let ExprField { ident, expr, span, is_shorthand : _, attrs, id, is_placeholder : _ } = f;
1076
1137
vis. visit_id ( id) ;
1077
1138
visit_attrs ( vis, attrs) ;
1078
1139
vis. visit_ident ( ident) ;
1079
1140
vis. visit_expr ( expr) ;
1080
1141
vis. visit_span ( span) ;
1142
+ }
1143
+
1144
+ pub fn walk_flat_map_expr_field < T : MutVisitor > (
1145
+ vis : & mut T ,
1146
+ mut f : ExprField ,
1147
+ ) -> SmallVec < [ ExprField ; 1 ] > {
1148
+ vis. visit_expr_field ( & mut f) ;
1081
1149
smallvec ! [ f]
1082
1150
}
1083
1151
@@ -1331,18 +1399,19 @@ pub fn walk_crate<T: MutVisitor>(vis: &mut T, krate: &mut Crate) {
1331
1399
vis. visit_span ( inject_use_span) ;
1332
1400
}
1333
1401
1334
- pub fn walk_flat_map_item < K : WalkItemKind < Ctxt = ( ) > > (
1335
- visitor : & mut impl MutVisitor ,
1336
- item : P < Item < K > > ,
1337
- ) -> SmallVec < [ P < Item < K > > ; 1 ] > {
1338
- walk_flat_map_assoc_item ( visitor, item, ( ) )
1402
+ pub fn walk_item ( visitor : & mut impl MutVisitor , item : & mut P < Item < impl WalkItemKind < Ctxt = ( ) > > > ) {
1403
+ walk_item_ctxt ( visitor, item, ( ) )
1404
+ }
1405
+
1406
+ pub fn walk_assoc_item ( visitor : & mut impl MutVisitor , item : & mut P < AssocItem > , ctxt : AssocCtxt ) {
1407
+ walk_item_ctxt ( visitor, item, ctxt)
1339
1408
}
1340
1409
1341
- pub fn walk_flat_map_assoc_item < K : WalkItemKind > (
1410
+ fn walk_item_ctxt < K : WalkItemKind > (
1342
1411
visitor : & mut impl MutVisitor ,
1343
- mut item : P < Item < K > > ,
1412
+ item : & mut P < Item < K > > ,
1344
1413
ctxt : K :: Ctxt ,
1345
- ) -> SmallVec < [ P < Item < K > > ; 1 ] > {
1414
+ ) {
1346
1415
let Item { ident, attrs, id, kind, vis, span, tokens } = item. deref_mut ( ) ;
1347
1416
visitor. visit_id ( id) ;
1348
1417
visit_attrs ( visitor, attrs) ;
@@ -1351,6 +1420,27 @@ pub fn walk_flat_map_assoc_item<K: WalkItemKind>(
1351
1420
kind. walk ( * span, * id, ident, vis, ctxt, visitor) ;
1352
1421
visit_lazy_tts ( visitor, tokens) ;
1353
1422
visitor. visit_span ( span) ;
1423
+ }
1424
+
1425
+ pub fn walk_flat_map_item ( vis : & mut impl MutVisitor , mut item : P < Item > ) -> SmallVec < [ P < Item > ; 1 ] > {
1426
+ vis. visit_item ( & mut item) ;
1427
+ smallvec ! [ item]
1428
+ }
1429
+
1430
+ pub fn walk_flat_map_foreign_item (
1431
+ vis : & mut impl MutVisitor ,
1432
+ mut item : P < ForeignItem > ,
1433
+ ) -> SmallVec < [ P < ForeignItem > ; 1 ] > {
1434
+ vis. visit_foreign_item ( & mut item) ;
1435
+ smallvec ! [ item]
1436
+ }
1437
+
1438
+ pub fn walk_flat_map_assoc_item (
1439
+ vis : & mut impl MutVisitor ,
1440
+ mut item : P < AssocItem > ,
1441
+ ctxt : AssocCtxt ,
1442
+ ) -> SmallVec < [ P < AssocItem > ; 1 ] > {
1443
+ vis. visit_assoc_item ( & mut item, ctxt) ;
1354
1444
smallvec ! [ item]
1355
1445
}
1356
1446
0 commit comments