@@ -222,28 +222,30 @@ macro_rules! e {
222
222
/// purpose is to calculate the correct enum values.
223
223
///
224
224
/// See <https://github.com/rust-lang/libc/issues/4419> for more.
225
+ // FIXME(ctest): ctest doesn't recognize the `literal` fragment specifier or the `?` kleene. See
226
+ // inline comments for how this should be updated once ctest is fixed.
225
227
macro_rules! c_enum {
226
228
(
227
- $( #[ repr( $repr: ty) ] ) ?
229
+ $( #[ repr( $repr: ty) ] ) * /* ? */
228
230
enum $ty_name: ident {
229
- $( $variant: ident $( = $value: literal) ? , ) +
231
+ $( $variant: ident $( = $value: expr /* literal */ ) * /* ? */ , ) +
230
232
}
231
233
) => {
232
- pub type $ty_name = c_enum!( @ty $( $repr) ? ) ;
233
- c_enum!( @one; $ty_name; 0 ; $( $variant $( = $value) ? , ) +) ;
234
+ pub type $ty_name = c_enum!( @ty $( $repr) * ) ;
235
+ c_enum!( @one; $ty_name; 0 ; $( $variant $( = $value) * , ) +) ;
234
236
} ;
235
237
236
238
// Matcher for a single variant
237
239
( @one; $_ty_name: ident; $_idx: expr; ) => { } ;
238
240
(
239
241
@one; $ty_name: ident; $default_val: expr;
240
- $variant: ident $( = $value: literal) ? ,
242
+ $variant: ident $( = $value: expr /* literal */ ) * /* ? */ ,
241
243
$( $tail: tt) *
242
244
) => {
243
245
pub const $variant: $ty_name = {
244
246
#[ allow( unused_variables) ]
245
247
let r = $default_val;
246
- $( let r = $value; ) ?
248
+ $( let r = $value; ) *
247
249
r
248
250
} ;
249
251
@@ -254,7 +256,7 @@ macro_rules! c_enum {
254
256
255
257
// Use a specific type if provided, otherwise default to `c_uint`
256
258
( @ty $repr: ty) => { $repr } ;
257
- ( @ty) => { $ crate:: c_uint } ;
259
+ ( @ty) => { crate :: c_uint } ;
258
260
}
259
261
260
262
// This is a pretty horrible hack to allow us to conditionally mark some functions as 'const',
0 commit comments