@@ -215,14 +215,15 @@ impl<'a> AstValidator<'a> {
215
215
}
216
216
217
217
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) ;
226
227
} else {
227
228
self . visit_field_def ( field) ;
228
229
}
@@ -291,13 +292,11 @@ impl<'a> AstValidator<'a> {
291
292
}
292
293
293
294
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 } ) ;
301
300
}
302
301
}
303
302
@@ -1180,28 +1179,40 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1180
1179
( BoundKind :: SuperTraits , TraitBoundModifier :: Maybe ) => {
1181
1180
self . err_handler ( ) . emit_err ( errors:: OptionalTraitSupertrait {
1182
1181
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 ) ,
1184
1183
} ) ;
1185
1184
}
1186
1185
( 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 } ) ;
1188
1187
}
1189
- ( _, TraitBoundModifier :: MaybeConst ) if let Some ( reason) = & self . disallow_tilde_const => {
1188
+ ( _, TraitBoundModifier :: MaybeConst )
1189
+ if let Some ( reason) = & self . disallow_tilde_const =>
1190
+ {
1190
1191
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
+ }
1194
1201
} ;
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 } ) ;
1199
1204
}
1200
1205
( _, 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
+ } ) ;
1202
1210
}
1203
1211
( _, 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
+ } ) ;
1205
1216
}
1206
1217
_ => { }
1207
1218
}
@@ -1214,7 +1225,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1214
1225
{
1215
1226
for arg in & args. args {
1216
1227
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 } ) ;
1218
1230
}
1219
1231
}
1220
1232
}
0 commit comments