@@ -234,9 +234,7 @@ pub trait Visitor<'v>: Sized {
234
234
#[ allow( unused_variables) ]
235
235
fn visit_nested_item ( & mut self , id : ItemId ) {
236
236
let opt_item = self . nested_visit_map ( ) . inter ( ) . map ( |map| map. item ( id. id ) ) ;
237
- if let Some ( item) = opt_item {
238
- self . visit_item ( item) ;
239
- }
237
+ walk_list ! ( self , visit_item, opt_item) ;
240
238
}
241
239
242
240
/// Like `visit_nested_item()`, but for trait items. See
@@ -245,9 +243,7 @@ pub trait Visitor<'v>: Sized {
245
243
#[ allow( unused_variables) ]
246
244
fn visit_nested_trait_item ( & mut self , id : TraitItemId ) {
247
245
let opt_item = self . nested_visit_map ( ) . inter ( ) . map ( |map| map. trait_item ( id) ) ;
248
- if let Some ( item) = opt_item {
249
- self . visit_trait_item ( item) ;
250
- }
246
+ walk_list ! ( self , visit_trait_item, opt_item) ;
251
247
}
252
248
253
249
/// Like `visit_nested_item()`, but for impl items. See
@@ -256,9 +252,7 @@ pub trait Visitor<'v>: Sized {
256
252
#[ allow( unused_variables) ]
257
253
fn visit_nested_impl_item ( & mut self , id : ImplItemId ) {
258
254
let opt_item = self . nested_visit_map ( ) . inter ( ) . map ( |map| map. impl_item ( id) ) ;
259
- if let Some ( item) = opt_item {
260
- self . visit_impl_item ( item) ;
261
- }
255
+ walk_list ! ( self , visit_impl_item, opt_item) ;
262
256
}
263
257
264
258
/// Invoked to visit the body of a function, method or closure. Like
@@ -267,9 +261,7 @@ pub trait Visitor<'v>: Sized {
267
261
/// the body.
268
262
fn visit_nested_body ( & mut self , id : BodyId ) {
269
263
let opt_body = self . nested_visit_map ( ) . intra ( ) . map ( |map| map. body ( id) ) ;
270
- if let Some ( body) = opt_body {
271
- self . visit_body ( body) ;
272
- }
264
+ walk_list ! ( self , visit_body, opt_body) ;
273
265
}
274
266
275
267
fn visit_param ( & mut self , param : & ' v Param < ' v > ) {
@@ -690,9 +682,7 @@ pub fn walk_qpath<'v, V: Visitor<'v>>(
690
682
) {
691
683
match * qpath {
692
684
QPath :: Resolved ( ref maybe_qself, ref path) => {
693
- if let Some ( ref qself) = * maybe_qself {
694
- visitor. visit_ty ( qself) ;
695
- }
685
+ walk_list ! ( visitor, visit_ty, maybe_qself) ;
696
686
visitor. visit_path ( path, id)
697
687
}
698
688
QPath :: TypeRelative ( ref qself, ref segment) => {
@@ -714,9 +704,7 @@ pub fn walk_path_segment<'v, V: Visitor<'v>>(
714
704
segment : & ' v PathSegment < ' v > ,
715
705
) {
716
706
visitor. visit_ident ( segment. ident ) ;
717
- if let Some ( id) = segment. hir_id {
718
- visitor. visit_id ( id) ;
719
- }
707
+ walk_list ! ( visitor, visit_id, segment. hir_id) ;
720
708
if let Some ( ref args) = segment. args {
721
709
visitor. visit_generic_args ( path_span, args) ;
722
710
}
@@ -1005,9 +993,7 @@ pub fn walk_struct_def<'v, V: Visitor<'v>>(
1005
993
visitor : & mut V ,
1006
994
struct_definition : & ' v VariantData < ' v > ,
1007
995
) {
1008
- if let Some ( ctor_hir_id) = struct_definition. ctor_hir_id ( ) {
1009
- visitor. visit_id ( ctor_hir_id) ;
1010
- }
996
+ walk_list ! ( visitor, visit_id, struct_definition. ctor_hir_id( ) ) ;
1011
997
walk_list ! ( visitor, visit_struct_field, struct_definition. fields( ) ) ;
1012
998
}
1013
999
@@ -1127,15 +1113,11 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
1127
1113
visitor. visit_qpath ( qpath, expression. hir_id , expression. span ) ;
1128
1114
}
1129
1115
ExprKind :: Break ( ref destination, ref opt_expr) => {
1130
- if let Some ( ref label) = destination. label {
1131
- visitor. visit_label ( label) ;
1132
- }
1116
+ walk_list ! ( visitor, visit_label, & destination. label) ;
1133
1117
walk_list ! ( visitor, visit_expr, opt_expr) ;
1134
1118
}
1135
1119
ExprKind :: Continue ( ref destination) => {
1136
- if let Some ( ref label) = destination. label {
1137
- visitor. visit_label ( label) ;
1138
- }
1120
+ walk_list ! ( visitor, visit_label, & destination. label) ;
1139
1121
}
1140
1122
ExprKind :: Ret ( ref optional_expression) => {
1141
1123
walk_list ! ( visitor, visit_expr, optional_expression) ;
0 commit comments