diff --git a/src/bbbul.rs b/src/bbbul.rs index acd3f96..f46594a 100644 --- a/src/bbbul.rs +++ b/src/bbbul.rs @@ -66,6 +66,7 @@ impl Node { #[allow(clippy::mut_from_ref)] fn new_in(block_size: usize, bump: &Bump) -> &mut Node { + check_node_base_size(); let total_size = Self::BASE_SIZE + block_size; let align = mem::align_of::>>(); let layout = Layout::from_size_align(total_size, align).unwrap(); @@ -92,6 +93,15 @@ impl Node { } } +fn check_node_base_size() { + let size = Node::BASE_SIZE; + debug_assert!( + size == 16, + "⚠️ Node::BASE_SIZE is {}, but expected 16 — check architecture assumptions", + size + ); +} + impl<'bump, B: BitPacker> Bbbul<'bump, B> { /// Construct a new `Bbbul` type. pub fn new_in(bump: &'bump Bump) -> Bbbul<'bump, B> { @@ -295,11 +305,6 @@ unsafe fn fatten(data: NonNull, len: usize) -> *mut Node { ptr::slice_from_raw_parts_mut(data.as_ptr(), len) as *mut Node } -/// Make sure that Node base size has a size of 16 bytes. -const _NODE_SIZE_16: () = if Node::BASE_SIZE != 16 { - unreachable!() -}; - /// Make sure that Bbbul does not need drop. const _BBBUL_NEEDS_DROP: () = if needs_drop::>() { unreachable!()