@@ -233,32 +233,33 @@ macro_rules! e {
233233macro_rules!  c_enum { 
234234    ( $( 
235235        $( #[ repr( $repr: ty) ] ) ?
236-         pub  enum  $ty_name: ident { 
236+         pub  enum  $( $ ty_name: ident) ?  { 
237237            $( $variant: ident $( = $value: expr) ?, ) +
238238        } 
239239    ) +)  => { 
240-         $( c_enum!( @expand; 
241-             $( #[ repr( $repr) ] ) ?
242-             pub  enum  $ty_name { 
243-                 $( $variant $( = $value) ?, ) +
244-             } 
245-         ) ; ) +
240+         $( c_enum!( @expand_repr;  $( $repr) ?;  $( $ty_name) ?;  $( $variant $( = $value) ?, ) +) ; ) +
246241    } ; 
247242
248-     ( @expand; 
249-         $( #[ repr( $repr: ty) ] ) ?
250-         pub  enum  $ty_name: ident { 
251-             $( $variant: ident $( = $value: expr) ?, ) +
252-         } 
253-     )  => { 
254-         pub  type  $ty_name = c_enum!( @ty $( $repr) ?) ; 
255-         c_enum!( @one;  $ty_name;  0 ;  $( $variant $( = $value) ?, ) +) ; 
243+     ( @expand_repr;          ;  $( $ty_name: ident) ?;  $( $variants: tt) * )  => { 
244+         // Use a specific type if provided, otherwise default to `CEnumRepr` 
245+         c_enum!( @expand_tyname;  $crate:: prelude:: CEnumRepr ;  $( $ty_name) ?;  $( $variants) * ) ; 
246+     } ; 
247+     ( @expand_repr;  $repr: ty;  $( $ty_name: ident) ?;  $( $variants: tt) * )  => { 
248+         c_enum!( @expand_tyname;  $repr;                       $( $ty_name) ?;  $( $variants) * ) ; 
249+     } ; 
250+ 
251+     ( @expand_tyname;  $repr: ty;                ;  $( $variants: tt) * )  => { 
252+         c_enum!( @one;  $repr;     0 ;  $( $variants) * ) ; 
253+     } ; 
254+     ( @expand_tyname;  $repr: ty;  $ty_name: ident;  $( $variants: tt) * )  => { 
255+         pub  type  $ty_name = $repr; 
256+         c_enum!( @one;  $ty_name;  0 ;  $( $variants) * ) ; 
256257    } ; 
257258
258259    // Matcher for a single variant 
259-     ( @one;  $_ty_name: ident ;  $_idx: expr; )  => { } ; 
260+     ( @one;  $_ty_name: ty ;  $_idx: expr; )  => { } ; 
260261    ( 
261-         @one;  $ty_name: ident ;  $default_val: expr; 
262+         @one;  $ty_name: ty ;  $default_val: expr; 
262263        $variant: ident $( = $value: expr) ?, 
263264        $( $tail: tt) * 
264265    )  => { 
@@ -273,10 +274,6 @@ macro_rules! c_enum {
273274        // set explicitly. 
274275        c_enum!( @one;  $ty_name;  $variant + 1 ;  $( $tail) * ) ; 
275276    } ; 
276- 
277-     // Use a specific type if provided, otherwise default to `CEnumRepr` 
278-     ( @ty $repr: ty)  => {  $repr } ; 
279-     ( @ty)  => {  $crate:: prelude:: CEnumRepr  } ; 
280277} 
281278
282279// This is a pretty horrible hack to allow us to conditionally mark some functions as 'const', 
@@ -449,7 +446,7 @@ mod tests {
449446        // C enums always take one more than the previous value, unless set to a specific 
450447        // value. Duplicates are allowed. 
451448        c_enum !  { 
452-             pub  enum  e  { 
449+             pub  enum  { 
453450                VAR0 , 
454451                VAR2_0  = 2 , 
455452                VAR3_0 , 
0 commit comments