@@ -234,9 +234,7 @@ pub trait Visitor<'v>: Sized {
234234 #[ allow( unused_variables) ]
235235 fn visit_nested_item ( & mut self , id : ItemId ) {
236236 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) ;
240238 }
241239
242240 /// Like `visit_nested_item()`, but for trait items. See
@@ -245,9 +243,7 @@ pub trait Visitor<'v>: Sized {
245243 #[ allow( unused_variables) ]
246244 fn visit_nested_trait_item ( & mut self , id : TraitItemId ) {
247245 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) ;
251247 }
252248
253249 /// Like `visit_nested_item()`, but for impl items. See
@@ -256,9 +252,7 @@ pub trait Visitor<'v>: Sized {
256252 #[ allow( unused_variables) ]
257253 fn visit_nested_impl_item ( & mut self , id : ImplItemId ) {
258254 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) ;
262256 }
263257
264258 /// Invoked to visit the body of a function, method or closure. Like
@@ -267,9 +261,7 @@ pub trait Visitor<'v>: Sized {
267261 /// the body.
268262 fn visit_nested_body ( & mut self , id : BodyId ) {
269263 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) ;
273265 }
274266
275267 fn visit_param ( & mut self , param : & ' v Param < ' v > ) {
@@ -690,9 +682,7 @@ pub fn walk_qpath<'v, V: Visitor<'v>>(
690682) {
691683 match * qpath {
692684 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) ;
696686 visitor. visit_path ( path, id)
697687 }
698688 QPath :: TypeRelative ( ref qself, ref segment) => {
@@ -714,9 +704,7 @@ pub fn walk_path_segment<'v, V: Visitor<'v>>(
714704 segment : & ' v PathSegment < ' v > ,
715705) {
716706 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) ;
720708 if let Some ( ref args) = segment. args {
721709 visitor. visit_generic_args ( path_span, args) ;
722710 }
@@ -1005,9 +993,7 @@ pub fn walk_struct_def<'v, V: Visitor<'v>>(
1005993 visitor : & mut V ,
1006994 struct_definition : & ' v VariantData < ' v > ,
1007995) {
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( ) ) ;
1011997 walk_list ! ( visitor, visit_struct_field, struct_definition. fields( ) ) ;
1012998}
1013999
@@ -1127,15 +1113,11 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
11271113 visitor. visit_qpath ( qpath, expression. hir_id , expression. span ) ;
11281114 }
11291115 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) ;
11331117 walk_list ! ( visitor, visit_expr, opt_expr) ;
11341118 }
11351119 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) ;
11391121 }
11401122 ExprKind :: Ret ( ref optional_expression) => {
11411123 walk_list ! ( visitor, visit_expr, optional_expression) ;
0 commit comments