Skip to content

Commit 6e12527

Browse files
committed
macros: Work around ctest bugs
Some of our seemingly random failures probably come from this expansion. Work around ctest for now.
1 parent 3451a9d commit 6e12527

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/macros.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
221223
macro_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:ident /* 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:ident /* 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',

0 commit comments

Comments
 (0)