@@ -713,6 +713,23 @@ impl<'a> Parser<'a> {
713713 result
714714 }
715715
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+
716733 // NB: Do not use this function unless you actually plan to place the
717734 // spanned list in the AST.
718735 pub fn parse_seq < T > (
@@ -3013,7 +3030,7 @@ impl<'a> Parser<'a> {
30133030 self . expect ( & token:: RPAREN ) ;
30143031 pat = PatEnum ( enum_path, None ) ;
30153032 } else {
3016- args = self . parse_unspanned_seq (
3033+ args = self . parse_enum_variant_seq (
30173034 & token:: LPAREN ,
30183035 & token:: RPAREN ,
30193036 seq_sep_trailing_disallowed ( token:: COMMA ) ,
@@ -4431,7 +4448,7 @@ impl<'a> Parser<'a> {
44314448 kind = StructVariantKind ( self . parse_struct_def( ) ) ;
44324449 } else if self . token == token:: LPAREN {
44334450 all_nullary = false ;
4434- let arg_tys = self . parse_unspanned_seq (
4451+ let arg_tys = self . parse_enum_variant_seq (
44354452 & token:: LPAREN ,
44364453 & token:: RPAREN ,
44374454 seq_sep_trailing_disallowed( token:: COMMA ) ,
0 commit comments