@@ -713,6 +713,23 @@ impl<'a> Parser<'a> {
713
713
result
714
714
}
715
715
716
+ // parse a sequence parameter of enum variant. For consistency purposes,
717
+ // these should not be empty.
718
+ pub fn parse_enum_variant_seq < T > (
719
+ & mut self ,
720
+ bra : & token:: Token ,
721
+ ket : & token:: Token ,
722
+ sep : SeqSep ,
723
+ f: |& mut Parser | -> T )
724
+ -> Vec < T > {
725
+ let result = self . parse_unspanned_seq ( bra, ket, sep, f) ;
726
+ if result. is_empty ( ) {
727
+ self . span_err ( self . last_span ,
728
+ "nullary enum variants are written with no trailing `( )`" ) ;
729
+ }
730
+ result
731
+ }
732
+
716
733
// NB: Do not use this function unless you actually plan to place the
717
734
// spanned list in the AST.
718
735
pub fn parse_seq < T > (
@@ -3013,7 +3030,7 @@ impl<'a> Parser<'a> {
3013
3030
self . expect ( & token:: RPAREN ) ;
3014
3031
pat = PatEnum ( enum_path, None ) ;
3015
3032
} else {
3016
- args = self . parse_unspanned_seq (
3033
+ args = self . parse_enum_variant_seq (
3017
3034
& token:: LPAREN ,
3018
3035
& token:: RPAREN ,
3019
3036
seq_sep_trailing_disallowed ( token:: COMMA ) ,
@@ -4431,7 +4448,7 @@ impl<'a> Parser<'a> {
4431
4448
kind = StructVariantKind ( self . parse_struct_def( ) ) ;
4432
4449
} else if self . token == token:: LPAREN {
4433
4450
all_nullary = false ;
4434
- let arg_tys = self . parse_unspanned_seq (
4451
+ let arg_tys = self . parse_enum_variant_seq (
4435
4452
& token:: LPAREN ,
4436
4453
& token:: RPAREN ,
4437
4454
seq_sep_trailing_disallowed( token:: COMMA ) ,
0 commit comments