From 4ecabc61b15d944438d404fb755609705def249f Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Sun, 7 Jan 2024 10:56:43 +0100 Subject: [PATCH] Ensure no block ABI types have trailing padding --- crates/block2/src/abi.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/crates/block2/src/abi.rs b/crates/block2/src/abi.rs index 87bd0e147..0ea8549c5 100644 --- a/crates/block2/src/abi.rs +++ b/crates/block2/src/abi.rs @@ -296,3 +296,26 @@ pub(crate) struct BlockDescriptorCopyDisposeSignature { #[doc(alias = "signature")] pub(crate) encoding: *const c_char, } + +#[cfg(test)] +mod tests { + use super::*; + + fn assert_no_trailing_padding() { + struct AddU8 { + t: T, + extra: u8, + } + assert_ne!(core::mem::size_of::(), core::mem::size_of::>()); + } + + #[test] + fn no_types_have_padding() { + assert_no_trailing_padding::(); + assert_no_trailing_padding::(); + assert_no_trailing_padding::(); + assert_no_trailing_padding::(); + assert_no_trailing_padding::(); + assert_no_trailing_padding::(); + } +}