@@ -215,14 +215,15 @@ impl<'a> AstValidator<'a> {
215215 }
216216
217217 fn visit_struct_field_def ( & mut self , field : & ' a FieldDef ) {
218- if let Some ( ident) = field. ident &&
219- ident. name == kw:: Underscore {
220- self . check_unnamed_field_ty ( & field. ty , ident. span ) ;
221- self . visit_vis ( & field. vis ) ;
222- self . visit_ident ( ident) ;
223- self . visit_ty_common ( & field. ty ) ;
224- self . walk_ty ( & field. ty ) ;
225- walk_list ! ( self , visit_attribute, & field. attrs) ;
218+ if let Some ( ident) = field. ident
219+ && ident. name == kw:: Underscore
220+ {
221+ self . check_unnamed_field_ty ( & field. ty , ident. span ) ;
222+ self . visit_vis ( & field. vis ) ;
223+ self . visit_ident ( ident) ;
224+ self . visit_ty_common ( & field. ty ) ;
225+ self . walk_ty ( & field. ty ) ;
226+ walk_list ! ( self , visit_attribute, & field. attrs) ;
226227 } else {
227228 self . visit_field_def ( field) ;
228229 }
@@ -291,13 +292,11 @@ impl<'a> AstValidator<'a> {
291292 }
292293
293294 fn deny_unnamed_field ( & self , field : & FieldDef ) {
294- if let Some ( ident) = field. ident &&
295- ident. name == kw:: Underscore {
296- self . err_handler ( )
297- . emit_err ( errors:: InvalidUnnamedField {
298- span : field. span ,
299- ident_span : ident. span
300- } ) ;
295+ if let Some ( ident) = field. ident
296+ && ident. name == kw:: Underscore
297+ {
298+ self . err_handler ( )
299+ . emit_err ( errors:: InvalidUnnamedField { span : field. span , ident_span : ident. span } ) ;
301300 }
302301 }
303302
@@ -1180,28 +1179,40 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
11801179 ( BoundKind :: SuperTraits , TraitBoundModifier :: Maybe ) => {
11811180 self . err_handler ( ) . emit_err ( errors:: OptionalTraitSupertrait {
11821181 span : poly. span ,
1183- path_str : pprust:: path_to_string ( & poly. trait_ref . path )
1182+ path_str : pprust:: path_to_string ( & poly. trait_ref . path ) ,
11841183 } ) ;
11851184 }
11861185 ( BoundKind :: TraitObject , TraitBoundModifier :: Maybe ) => {
1187- self . err_handler ( ) . emit_err ( errors:: OptionalTraitObject { span : poly. span } ) ;
1186+ self . err_handler ( ) . emit_err ( errors:: OptionalTraitObject { span : poly. span } ) ;
11881187 }
1189- ( _, TraitBoundModifier :: MaybeConst ) if let Some ( reason) = & self . disallow_tilde_const => {
1188+ ( _, TraitBoundModifier :: MaybeConst )
1189+ if let Some ( reason) = & self . disallow_tilde_const =>
1190+ {
11901191 let reason = match reason {
1191- DisallowTildeConstContext :: TraitObject => errors:: TildeConstReason :: TraitObject ,
1192- DisallowTildeConstContext :: Fn ( FnKind :: Closure ( ..) ) => errors:: TildeConstReason :: Closure ,
1193- DisallowTildeConstContext :: Fn ( FnKind :: Fn ( _, ident, ..) ) => errors:: TildeConstReason :: Function { ident : ident. span } ,
1192+ DisallowTildeConstContext :: TraitObject => {
1193+ errors:: TildeConstReason :: TraitObject
1194+ }
1195+ DisallowTildeConstContext :: Fn ( FnKind :: Closure ( ..) ) => {
1196+ errors:: TildeConstReason :: Closure
1197+ }
1198+ DisallowTildeConstContext :: Fn ( FnKind :: Fn ( _, ident, ..) ) => {
1199+ errors:: TildeConstReason :: Function { ident : ident. span }
1200+ }
11941201 } ;
1195- self . err_handler ( ) . emit_err ( errors:: TildeConstDisallowed {
1196- span : bound. span ( ) ,
1197- reason
1198- } ) ;
1202+ self . err_handler ( )
1203+ . emit_err ( errors:: TildeConstDisallowed { span : bound. span ( ) , reason } ) ;
11991204 }
12001205 ( _, TraitBoundModifier :: MaybeConstMaybe ) => {
1201- self . err_handler ( ) . emit_err ( errors:: OptionalConstExclusive { span : bound. span ( ) , modifier : "?" } ) ;
1206+ self . err_handler ( ) . emit_err ( errors:: OptionalConstExclusive {
1207+ span : bound. span ( ) ,
1208+ modifier : "?" ,
1209+ } ) ;
12021210 }
12031211 ( _, TraitBoundModifier :: MaybeConstNegative ) => {
1204- self . err_handler ( ) . emit_err ( errors:: OptionalConstExclusive { span : bound. span ( ) , modifier : "!" } ) ;
1212+ self . err_handler ( ) . emit_err ( errors:: OptionalConstExclusive {
1213+ span : bound. span ( ) ,
1214+ modifier : "!" ,
1215+ } ) ;
12051216 }
12061217 _ => { }
12071218 }
@@ -1214,7 +1225,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
12141225 {
12151226 for arg in & args. args {
12161227 if let ast:: AngleBracketedArg :: Constraint ( constraint) = arg {
1217- self . err_handler ( ) . emit_err ( errors:: ConstraintOnNegativeBound { span : constraint. span } ) ;
1228+ self . err_handler ( )
1229+ . emit_err ( errors:: ConstraintOnNegativeBound { span : constraint. span } ) ;
12181230 }
12191231 }
12201232 }
0 commit comments