@@ -218,28 +218,29 @@ macro_rules! e {
218218/// purpose is to calculate the correct enum values.
219219///
220220/// See <https://github.com/rust-lang/libc/issues/4419> for more.
221+ // FIXME(ctest): ctest doesn't like `?` kleenes, `literal` fragments, or `$crate`. See inline
222+ // comments for what eventually should be fixed.
221223macro_rules! c_enum {
222224 (
223- $( #[ repr( $repr: ty) ] ) ?
225+ $( #[ repr( $repr: ty) ] ) * /* ? */
224226 $ty_name: ident {
225- $( $variant: ident $( = $value: literal) ? , ) +
227+ $( $variant: ident $( = $value: tt /* literal */ ) * /* ? */ , ) +
226228 }
227229 ) => {
228- pub type $ty_name = c_enum!( @ty $( $repr) ? ) ;
229- c_enum!( @one; $ty_name; 0 ; $( $variant $( = $value) ? , ) +) ;
230+ pub type $ty_name = c_enum!( @ty $( $repr) * ) ;
231+ c_enum!( @one; $ty_name; 0 ; $( $variant $( = $value) * , ) +) ;
230232 } ;
231-
232233 // Matcher for a single variant
233234 ( @one; $_ty_name: ident; $_idx: expr; ) => { } ;
234235 (
235236 @one; $ty_name: ident; $default_val: expr;
236- $variant: ident $( = $value: literal) ? ,
237+ $variant: ident $( = $value: tt /* literal */ ) * /* ? */ ,
237238 $( $tail: tt) *
238239 ) => {
239240 pub const $variant: $ty_name = {
240241 #[ allow( unused_variables) ]
241242 let r = $default_val;
242- $( let r = $value; ) ?
243+ $( let r = $value; ) *
243244 r
244245 } ;
245246
@@ -250,7 +251,7 @@ macro_rules! c_enum {
250251
251252 // Use a specific type if provided, otherwise default to `c_uint`
252253 ( @ty $repr: ty) => { $repr } ;
253- ( @ty) => { $crate:: c_uint } ;
254+ ( @ty) => { /* $crate:: */ c_uint } ;
254255}
255256
256257// This is a pretty horrible hack to allow us to conditionally mark some functions as 'const',
@@ -371,6 +372,8 @@ macro_rules! __item {
371372
372373#[ cfg( test) ]
373374mod tests {
375+ use crate :: c_uint;
376+
374377 #[ test]
375378 fn c_enumbasic ( ) {
376379 // By default, variants get sequential values.
0 commit comments