@@ -251,20 +251,6 @@ impl<'a> AstValidator<'a> {
251251 }
252252 }
253253
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-
268254 fn err_handler ( & self ) -> & rustc_errors:: Handler {
269255 & self . session . diagnostic ( )
270256 }
@@ -1005,8 +991,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1005991 visit:: walk_lifetime ( self , lifetime) ;
1006992 }
1007993
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 )
1010996 }
1011997
1012998 fn visit_item ( & mut self , item : & ' a Item ) {
@@ -1194,42 +1180,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
11941180 self . check_mod_file_item_asciionly ( item. ident ) ;
11951181 }
11961182 }
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, ..) => {
12171184 if vdata. fields ( ) . is_empty ( ) {
12181185 self . err_handler ( ) . span_err ( item. span , "unions cannot have zero fields" ) ;
12191186 }
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- }
12331187 }
12341188 ItemKind :: Const ( def, .., None ) => {
12351189 self . check_defaultness ( item. span , def) ;
0 commit comments