@@ -5052,7 +5052,7 @@ impl<'a> Parser<'a> {
50525052 fn parse_enum_def ( & mut self , _generics : & ast:: Generics ) -> EnumDef {
50535053 let mut variants = Vec :: new ( ) ;
50545054 let mut all_nullary = true ;
5055- let mut have_disr = false ;
5055+ let mut any_disr = None ;
50565056 while self . token != token:: RBRACE {
50575057 let variant_attrs = self . parse_outer_attributes ( ) ;
50585058 let vlo = self . span . lo ;
@@ -5084,8 +5084,8 @@ impl<'a> Parser<'a> {
50845084 }
50855085 kind = TupleVariantKind ( args) ;
50865086 } else if self . eat ( & token:: EQ ) {
5087- have_disr = true ;
50885087 disr_expr = Some ( self . parse_expr ( ) ) ;
5088+ any_disr = disr_expr. as_ref ( ) . map ( |expr| expr. span ) ;
50895089 kind = TupleVariantKind ( args) ;
50905090 } else {
50915091 kind = TupleVariantKind ( Vec :: new ( ) ) ;
@@ -5104,9 +5104,11 @@ impl<'a> Parser<'a> {
51045104 if !self . eat ( & token:: COMMA ) { break ; }
51055105 }
51065106 self . expect ( & token:: RBRACE ) ;
5107- if have_disr && !all_nullary {
5108- self . fatal ( "discriminator values can only be used with a c-like \
5109- enum") ;
5107+ match any_disr {
5108+ Some ( disr_span) if !all_nullary =>
5109+ self . span_err ( disr_span,
5110+ "discriminator values can only be used with a c-like enum" ) ,
5111+ _ => ( )
51105112 }
51115113
51125114 ast:: EnumDef { variants : variants }
0 commit comments