@@ -251,20 +251,6 @@ impl<'a> AstValidator<'a> {
251
251
}
252
252
}
253
253
254
- fn visit_struct_field_def ( & mut self , field : & ' a FieldDef ) {
255
- if let Some ( ident) = field. ident {
256
- if ident. name == kw:: Underscore {
257
- self . visit_vis ( & field. vis ) ;
258
- self . visit_ident ( ident) ;
259
- self . visit_ty_common ( & field. ty ) ;
260
- self . walk_ty ( & field. ty ) ;
261
- walk_list ! ( self , visit_attribute, & field. attrs) ;
262
- return ;
263
- }
264
- }
265
- self . visit_field_def ( field) ;
266
- }
267
-
268
254
fn err_handler ( & self ) -> & rustc_errors:: Handler {
269
255
& self . session . diagnostic ( )
270
256
}
@@ -1005,8 +991,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1005
991
visit:: walk_lifetime ( self , lifetime) ;
1006
992
}
1007
993
1008
- fn visit_field_def ( & mut self , s : & ' a FieldDef ) {
1009
- visit:: walk_field_def ( self , s )
994
+ fn visit_field_def ( & mut self , field : & ' a FieldDef ) {
995
+ visit:: walk_field_def ( self , field )
1010
996
}
1011
997
1012
998
fn visit_item ( & mut self , item : & ' a Item ) {
@@ -1194,42 +1180,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1194
1180
self . check_mod_file_item_asciionly ( item. ident ) ;
1195
1181
}
1196
1182
}
1197
- ItemKind :: Struct ( ref vdata, ref generics) => match vdata {
1198
- // Duplicating the `Visitor` logic allows catching all cases
1199
- // of `Anonymous(Struct, Union)` outside of a field struct or union.
1200
- //
1201
- // Inside `visit_ty` the validator catches every `Anonymous(Struct, Union)` it
1202
- // encounters, and only on `ItemKind::Struct` and `ItemKind::Union`
1203
- // it uses `visit_ty_common`, which doesn't contain that specific check.
1204
- VariantData :: Struct ( ref fields, ..) => {
1205
- self . visit_vis ( & item. vis ) ;
1206
- self . visit_ident ( item. ident ) ;
1207
- self . visit_generics ( generics) ;
1208
- self . with_banned_assoc_ty_bound ( |this| {
1209
- walk_list ! ( this, visit_struct_field_def, fields) ;
1210
- } ) ;
1211
- walk_list ! ( self , visit_attribute, & item. attrs) ;
1212
- return ;
1213
- }
1214
- _ => { }
1215
- } ,
1216
- ItemKind :: Union ( ref vdata, ref generics) => {
1183
+ ItemKind :: Union ( ref vdata, ..) => {
1217
1184
if vdata. fields ( ) . is_empty ( ) {
1218
1185
self . err_handler ( ) . span_err ( item. span , "unions cannot have zero fields" ) ;
1219
1186
}
1220
- match vdata {
1221
- VariantData :: Struct ( ref fields, ..) => {
1222
- self . visit_vis ( & item. vis ) ;
1223
- self . visit_ident ( item. ident ) ;
1224
- self . visit_generics ( generics) ;
1225
- self . with_banned_assoc_ty_bound ( |this| {
1226
- walk_list ! ( this, visit_struct_field_def, fields) ;
1227
- } ) ;
1228
- walk_list ! ( self , visit_attribute, & item. attrs) ;
1229
- return ;
1230
- }
1231
- _ => { }
1232
- }
1233
1187
}
1234
1188
ItemKind :: Const ( def, .., None ) => {
1235
1189
self . check_defaultness ( item. span , def) ;
0 commit comments