diff --git a/src/bytes.rs b/src/bytes.rs index 0f1aaed..bbd7bdc 100644 --- a/src/bytes.rs +++ b/src/bytes.rs @@ -1348,7 +1348,12 @@ impl Drop for Shared { // This is a necessary invariant since we depend on allocating `Shared` a // shared object to implicitly carry the `KIND_ARC` flag in its pointer. // This flag is set when the LSB is 0. -const _: [(); 0 - mem::align_of::() % 2] = []; // Assert that the alignment of `Shared` is divisible by 2. +const _: () = { + assert!( + mem::align_of::() % 2 == 0, + "Shared alignment must be divisible by 2 for pointer tagging" + ); +}; static SHARED_VTABLE: Vtable = Vtable { clone: shared_clone, diff --git a/src/bytes_mut.rs b/src/bytes_mut.rs index b983bd1..ae808fa 100644 --- a/src/bytes_mut.rs +++ b/src/bytes_mut.rs @@ -92,7 +92,12 @@ impl Shared { // This is a necessary invariant since we depend on allocating `Shared` a // shared object to implicitly carry the `KIND_ARC` flag in its pointer. // This flag is set when the LSB is 0. -const _: [(); 0 - mem::align_of::() % 2] = []; // Assert that the alignment of `Shared` is divisible by 2. +const _: () = { + assert!( + mem::align_of::() % 2 == 0, + "Shared alignment must be divisible by 2 for pointer tagging" + ); +}; // Buffer storage strategy flags. const KIND_ARC: usize = 0b0;