Skip to content

Commit

Permalink
Ensure no block ABI types have trailing padding
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jan 7, 2024
1 parent 7e51d60 commit 4ecabc6
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions crates/block2/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>() {
struct AddU8<T> {
t: T,
extra: u8,
}
assert_ne!(core::mem::size_of::<T>(), core::mem::size_of::<AddU8<T>>());
}

#[test]
fn no_types_have_padding() {
assert_no_trailing_padding::<BlockHeader>();
assert_no_trailing_padding::<BlockDescriptorPtr>();
assert_no_trailing_padding::<BlockDescriptor>();
assert_no_trailing_padding::<BlockDescriptorCopyDispose>();
assert_no_trailing_padding::<BlockDescriptorSignature>();
assert_no_trailing_padding::<BlockDescriptorCopyDisposeSignature>();
}
}

0 comments on commit 4ecabc6

Please sign in to comment.