diff options
Diffstat (limited to 'vendor/rustix/src/check_types.rs')
-rw-r--r-- | vendor/rustix/src/check_types.rs | 70 |
1 files changed, 29 insertions, 41 deletions
diff --git a/vendor/rustix/src/check_types.rs b/vendor/rustix/src/check_types.rs index 2ba1f3f9e..861d7d7b5 100644 --- a/vendor/rustix/src/check_types.rs +++ b/vendor/rustix/src/check_types.rs @@ -3,16 +3,8 @@ /// Check that the size and alignment of a type match the `sys` bindings. macro_rules! check_type { ($struct:ident) => { - assert_eq!( - ( - core::mem::size_of::<$struct>(), - core::mem::align_of::<$struct>() - ), - ( - core::mem::size_of::<c::$struct>(), - core::mem::align_of::<c::$struct>() - ) - ); + assert_eq_size!($struct, c::$struct); + assert_eq_align!($struct, c::$struct); }; } @@ -20,13 +12,8 @@ macro_rules! check_type { /// renamed to avoid having types like `bindgen_ty_1` in the API. macro_rules! check_renamed_type { ($to:ident, $from:ident) => { - assert_eq!( - (core::mem::size_of::<$to>(), core::mem::align_of::<$to>()), - ( - core::mem::size_of::<c::$from>(), - core::mem::align_of::<c::$from>() - ) - ); + assert_eq_size!($to, c::$from); + assert_eq_align!($to, c::$from); }; } @@ -34,15 +21,16 @@ macro_rules! check_renamed_type { /// corresponding field in the `sys` bindings. macro_rules! check_struct_field { ($struct:ident, $field:ident) => { + const_assert_eq!( + memoffset::offset_of!($struct, $field), + memoffset::offset_of!(c::$struct, $field) + ); + + // This can't use `const_assert_eq` because `span_of` returns a + // `Range`, which can't be compared in const contexts. assert_eq!( - ( - memoffset::offset_of!($struct, $field), - memoffset::span_of!($struct, $field) - ), - ( - memoffset::offset_of!(c::$struct, $field), - memoffset::span_of!(c::$struct, $field) - ) + memoffset::span_of!($struct, $field), + memoffset::span_of!(c::$struct, $field) ); }; } @@ -51,15 +39,15 @@ macro_rules! check_struct_field { /// we've renamed to avoid having types like `bindgen_ty_1` in the API. macro_rules! check_struct_renamed_field { ($struct:ident, $to:ident, $from:ident) => { + const_assert_eq!( + memoffset::offset_of!($struct, $to), + memoffset::offset_of!(c::$struct, $from) + ); + + // As above, this can't use `const_assert_eq`. assert_eq!( - ( - memoffset::offset_of!($struct, $to), - memoffset::span_of!($struct, $to) - ), - ( - memoffset::offset_of!(c::$struct, $from), - memoffset::span_of!(c::$struct, $from) - ) + memoffset::span_of!($struct, $to), + memoffset::span_of!(c::$struct, $from) ); }; } @@ -68,15 +56,15 @@ macro_rules! check_struct_renamed_field { /// and a field are renamed. macro_rules! check_renamed_struct_renamed_field { ($to_struct:ident, $from_struct:ident, $to:ident, $from:ident) => { + const_assert_eq!( + memoffset::offset_of!($to_struct, $to), + memoffset::offset_of!(c::$from_struct, $from) + ); + + // As above, this can't use `const_assert_eq`. assert_eq!( - ( - memoffset::offset_of!($to_struct, $to), - memoffset::span_of!($to_struct, $to) - ), - ( - memoffset::offset_of!(c::$from_struct, $from), - memoffset::span_of!(c::$from_struct, $from) - ) + memoffset::span_of!($to_struct, $to), + memoffset::span_of!(c::$from_struct, $from) ); }; } |