@@ -128,17 +128,6 @@ impl<'a> Parser<'a> {
128
128
)
129
129
}
130
130
131
- /// Parse a type suitable for a field definition.
132
- /// The difference from `parse_ty` is that this version
133
- /// allows anonymous structs and unions.
134
- pub ( super ) fn parse_ty_for_field_def ( & mut self ) -> PResult < ' a , P < Ty > > {
135
- if self . can_begin_anon_struct_or_union ( ) {
136
- self . parse_anon_struct_or_union ( )
137
- } else {
138
- self . parse_ty ( )
139
- }
140
- }
141
-
142
131
/// Parse a type suitable for a function or function pointer parameter.
143
132
/// The difference from `parse_ty` is that this version allows `...`
144
133
/// (`CVarArgs`) at the top level of the type.
@@ -382,37 +371,6 @@ impl<'a> Parser<'a> {
382
371
if allow_qpath_recovery { self . maybe_recover_from_bad_qpath ( ty) } else { Ok ( ty) }
383
372
}
384
373
385
- /// Parse an anonymous struct or union (only for field definitions):
386
- /// ```ignore (feature-not-ready)
387
- /// #[repr(C)]
388
- /// struct Foo {
389
- /// _: struct { // anonymous struct
390
- /// x: u32,
391
- /// y: f64,
392
- /// }
393
- /// _: union { // anonymous union
394
- /// z: u32,
395
- /// w: f64,
396
- /// }
397
- /// }
398
- /// ```
399
- fn parse_anon_struct_or_union ( & mut self ) -> PResult < ' a , P < Ty > > {
400
- assert ! ( self . token. is_keyword( kw:: Union ) || self . token. is_keyword( kw:: Struct ) ) ;
401
- let is_union = self . token . is_keyword ( kw:: Union ) ;
402
-
403
- let lo = self . token . span ;
404
- self . bump ( ) ;
405
-
406
- let ( fields, _recovered) =
407
- self . parse_record_struct_body ( if is_union { "union" } else { "struct" } , lo, false ) ?;
408
- let span = lo. to ( self . prev_token . span ) ;
409
- self . psess . gated_spans . gate ( sym:: unnamed_fields, span) ;
410
- let id = ast:: DUMMY_NODE_ID ;
411
- let kind =
412
- if is_union { TyKind :: AnonUnion ( id, fields) } else { TyKind :: AnonStruct ( id, fields) } ;
413
- Ok ( self . mk_ty ( span, kind) )
414
- }
415
-
416
374
/// Parses either:
417
375
/// - `(TYPE)`, a parenthesized type.
418
376
/// - `(TYPE,)`, a tuple with a single field of type TYPE.
@@ -813,11 +771,6 @@ impl<'a> Parser<'a> {
813
771
Ok ( bounds)
814
772
}
815
773
816
- pub ( super ) fn can_begin_anon_struct_or_union ( & mut self ) -> bool {
817
- ( self . token . is_keyword ( kw:: Struct ) || self . token . is_keyword ( kw:: Union ) )
818
- && self . look_ahead ( 1 , |t| t == & token:: OpenDelim ( Delimiter :: Brace ) )
819
- }
820
-
821
774
/// Can the current token begin a bound?
822
775
fn can_begin_bound ( & mut self ) -> bool {
823
776
self . check_path ( )
0 commit comments