Skip to content

Commit

Permalink
Auto merge of #2985 - flba-eb:fix_s_macro_order, r=JohnTitor
Browse files Browse the repository at this point in the history
Enforce order of any `s_*!` macro calls

Before this change, only the order of `s!` was checked. After, it also checks `s_no_extra_traits!` and `s_paren!`. Only the order is checked, not the number of calls. This is required because multiple calls have to be allowed.
  • Loading branch information
bors committed Nov 1, 2022
2 parents 7d615f0 + 60b655d commit a2b0b4f
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 48 deletions.
6 changes: 6 additions & 0 deletions ci/style.rs
Expand Up @@ -142,6 +142,12 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) {
} else if line.starts_with("s! {") {
s_macros += 1;
State::Structs
} else if line.starts_with("s_no_extra_traits! {") {
// multiple macros of this type are allowed
State::Structs
} else if line.starts_with("s_paren! {") {
// multiple macros of this type are allowed
State::Structs
} else if line.starts_with("f! {") {
f_macros += 1;
State::FunctionDefinitions
Expand Down
22 changes: 11 additions & 11 deletions src/unix/bsd/freebsdlike/freebsd/aarch64.rs
Expand Up @@ -6,17 +6,6 @@ pub type time_t = i64;
pub type suseconds_t = i64;
pub type register_t = i64;

// should be pub(crate), but that requires Rust 1.18.0
cfg_if! {
if #[cfg(libc_const_size_of)] {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1;
} else {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = 8 - 1;
}
}

s_no_extra_traits! {
pub struct gpregs {
pub gp_x: [::register_t; 30],
Expand Down Expand Up @@ -44,6 +33,17 @@ s_no_extra_traits! {
}
}

// should be pub(crate), but that requires Rust 1.18.0
cfg_if! {
if #[cfg(libc_const_size_of)] {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1;
} else {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = 8 - 1;
}
}

cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for gpregs {
Expand Down
22 changes: 11 additions & 11 deletions src/unix/bsd/freebsdlike/freebsd/riscv64.rs
Expand Up @@ -6,17 +6,6 @@ pub type time_t = i64;
pub type suseconds_t = ::c_long;
pub type register_t = i64;

// should be pub(crate), but that requires Rust 1.18.0
cfg_if! {
if #[cfg(libc_const_size_of)] {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1;
} else {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = 8 - 1;
}
}

s_no_extra_traits! {
pub struct gpregs {
pub gp_ra: ::register_t,
Expand Down Expand Up @@ -46,6 +35,17 @@ s_no_extra_traits! {
}
}

// should be pub(crate), but that requires Rust 1.18.0
cfg_if! {
if #[cfg(libc_const_size_of)] {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1;
} else {
#[doc(hidden)]
pub const _ALIGNBYTES: usize = 8 - 1;
}
}

cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for gpregs {
Expand Down
48 changes: 24 additions & 24 deletions src/unix/solarish/solaris.rs
Expand Up @@ -26,6 +26,30 @@ s! {
}
}

s_no_extra_traits! {
#[cfg_attr(feature = "extra_traits", allow(missing_debug_implementations))]
pub union door_desc_t__d_data {
pub d_desc: door_desc_t__d_data__d_desc,
d_resv: [::c_int; 5], /* Check out /usr/include/sys/door.h */
}

#[cfg_attr(feature = "extra_traits", allow(missing_debug_implementations))]
pub struct door_desc_t {
pub d_attributes: door_attr_t,
pub d_data: door_desc_t__d_data,
}

#[cfg_attr(feature = "extra_traits", allow(missing_debug_implementations))]
pub struct door_arg_t {
pub data_ptr: *const ::c_char,
pub data_size: ::size_t,
pub desc_ptr: *const door_desc_t,
pub dec_num: ::c_uint,
pub rbuf: *const ::c_char,
pub rsize: ::size_t,
}
}

pub const PORT_SOURCE_POSTWAIT: ::c_int = 8;
pub const PORT_SOURCE_SIGNAL: ::c_int = 9;

Expand Down Expand Up @@ -75,27 +99,3 @@ extern "C" {

pub fn euidaccess(path: *const ::c_char, amode: ::c_int) -> ::c_int;
}

s_no_extra_traits! {
#[cfg_attr(feature = "extra_traits", allow(missing_debug_implementations))]
pub union door_desc_t__d_data {
pub d_desc: door_desc_t__d_data__d_desc,
d_resv: [::c_int; 5], /* Check out /usr/include/sys/door.h */
}

#[cfg_attr(feature = "extra_traits", allow(missing_debug_implementations))]
pub struct door_desc_t {
pub d_attributes: door_attr_t,
pub d_data: door_desc_t__d_data,
}

#[cfg_attr(feature = "extra_traits", allow(missing_debug_implementations))]
pub struct door_arg_t {
pub data_ptr: *const ::c_char,
pub data_size: ::size_t,
pub desc_ptr: *const door_desc_t,
pub dec_num: ::c_uint,
pub rbuf: *const ::c_char,
pub rsize: ::size_t,
}
}
3 changes: 1 addition & 2 deletions src/wasi.rs
Expand Up @@ -39,6 +39,7 @@ pub type blkcnt_t = i64;
pub type nfds_t = c_ulong;
pub type wchar_t = i32;
pub type nl_item = c_int;
pub type __wasi_rights_t = u64;

s_no_extra_traits! {
#[repr(align(16))]
Expand All @@ -48,8 +49,6 @@ s_no_extra_traits! {
}
}

pub type __wasi_rights_t = u64;

#[allow(missing_copy_implementations)]
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum FILE {}
Expand Down

0 comments on commit a2b0b4f

Please sign in to comment.