Skip to content

Commit 9d520fb

Browse files
authored
Merge pull request #4494 from tgross35/macro-add-keyword
Add the `enum` keyword to the `c_enum` macro
2 parents 168a85b + 19e04c8 commit 9d520fb

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

ci/style.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ while IFS= read -r file; do
2626

2727
# Turn all braced macro `foo! { /* ... */ }` invocations into
2828
# `fn foo_fmt_tmp() { /* ... */ }`.
29-
perl -pi -e 's/(?!macro_rules|c_enum)\b(\w+)!\s*\{/fn $1_fmt_tmp() {/g' "$file"
29+
perl -pi -e 's/(?!macro_rules)\b(\w+)!\s*\{/fn $1_fmt_tmp() {/g' "$file"
3030

3131
# Replace `if #[cfg(...)]` within `cfg_if` with `if cfg_tmp!([...])` which
3232
# `rustfmt` will format. We put brackets within the parens so it is easy to

src/macros.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ macro_rules! e {
223223
macro_rules! c_enum {
224224
(
225225
$(#[repr($repr:ty)])?
226-
$ty_name:ident {
226+
enum $ty_name:ident {
227227
$($variant:ident $(= $value:literal)?,)+
228228
}
229229
) => {
@@ -377,7 +377,7 @@ mod tests {
377377
fn c_enumbasic() {
378378
// By default, variants get sequential values.
379379
c_enum! {
380-
e {
380+
enum e {
381381
VAR0,
382382
VAR1,
383383
VAR2,
@@ -394,7 +394,7 @@ mod tests {
394394
// By default, variants get sequential values.
395395
c_enum! {
396396
#[repr(u16)]
397-
e {
397+
enum e {
398398
VAR0,
399399
}
400400
}
@@ -406,7 +406,7 @@ mod tests {
406406
fn c_enumset_value() {
407407
// Setting an explicit value resets the count.
408408
c_enum! {
409-
e {
409+
enum e {
410410
VAR2 = 2,
411411
VAR3,
412412
VAR4,
@@ -423,7 +423,7 @@ mod tests {
423423
// C enums always take one more than the previous value, unless set to a specific
424424
// value. Duplicates are allowed.
425425
c_enum! {
426-
e {
426+
enum e {
427427
VAR0,
428428
VAR2_0 = 2,
429429
VAR3_0,

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub type Elf64_Xword = u64;
3939
pub type iconv_t = *mut c_void;
4040

4141
c_enum! {
42-
fae_action {
42+
enum fae_action {
4343
FAE_OPEN,
4444
FAE_DUP2,
4545
FAE_CLOSE,

src/unix/linux_like/linux/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ cfg_if! {
8686
}
8787

8888
c_enum! {
89-
tpacket_versions {
89+
enum tpacket_versions {
9090
TPACKET_V1,
9191
TPACKET_V2,
9292
TPACKET_V3,
9393
}
9494
}
9595

9696
c_enum! {
97-
pid_type {
97+
enum pid_type {
9898
PIDTYPE_PID,
9999
PIDTYPE_TGID,
100100
PIDTYPE_PGID,
@@ -4528,14 +4528,14 @@ pub const RTNLGRP_STATS: c_uint = 0x24;
45284528

45294529
// linux/cn_proc.h
45304530
c_enum! {
4531-
proc_cn_mcast_op {
4531+
enum proc_cn_mcast_op {
45324532
PROC_CN_MCAST_LISTEN = 1,
45334533
PROC_CN_MCAST_IGNORE = 2,
45344534
}
45354535
}
45364536

45374537
c_enum! {
4538-
proc_cn_event {
4538+
enum proc_cn_event {
45394539
PROC_EVENT_NONE = 0x00000000,
45404540
PROC_EVENT_FORK = 0x00000001,
45414541
PROC_EVENT_EXEC = 0x00000002,

0 commit comments

Comments
 (0)