@@ -214,17 +214,37 @@ pub(crate) mod parsing {
214
214
/// Parses a named (braced struct) field.
215
215
#[ cfg_attr( doc_cfg, doc( cfg( feature = "parsing" ) ) ) ]
216
216
pub fn parse_named ( input : ParseStream ) -> Result < Self > {
217
+ let attrs = input. call ( Attribute :: parse_outer) ?;
218
+ let vis: Visibility = input. parse ( ) ?;
219
+
220
+ let unnamed_field = cfg ! ( feature = "full" ) && input. peek ( Token ! [ _] ) ;
221
+ let ident = if unnamed_field {
222
+ input. call ( Ident :: parse_any)
223
+ } else {
224
+ input. parse ( )
225
+ } ?;
226
+
227
+ let colon_token: Token ! [ : ] = input. parse ( ) ?;
228
+
229
+ let ty: Type = if unnamed_field
230
+ && ( input. peek ( Token ! [ struct ] )
231
+ || input. peek ( Token ! [ union ] ) && input. peek2 ( token:: Brace ) )
232
+ {
233
+ let begin = input. fork ( ) ;
234
+ input. call ( Ident :: parse_any) ?;
235
+ input. parse :: < FieldsNamed > ( ) ?;
236
+ Type :: Verbatim ( verbatim:: between ( & begin, input) )
237
+ } else {
238
+ input. parse ( ) ?
239
+ } ;
240
+
217
241
Ok ( Field {
218
- attrs : input . call ( Attribute :: parse_outer ) ? ,
219
- vis : input . parse ( ) ? ,
242
+ attrs,
243
+ vis,
220
244
mutability : FieldMutability :: None ,
221
- ident : Some ( if input. peek ( Token ! [ _] ) {
222
- input. call ( Ident :: parse_any)
223
- } else {
224
- input. parse ( )
225
- } ?) ,
226
- colon_token : Some ( input. parse ( ) ?) ,
227
- ty : input. parse ( ) ?,
245
+ ident : Some ( ident) ,
246
+ colon_token : Some ( colon_token) ,
247
+ ty,
228
248
} )
229
249
}
230
250
0 commit comments