From c7de68ae6f68d78124d8301c28a6aae7a7f6eb02 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 29 Jul 2022 14:48:47 -0700 Subject: [PATCH] Avoid regression --- utils/zerovec/src/zerovec/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/zerovec/src/zerovec/mod.rs b/utils/zerovec/src/zerovec/mod.rs index a44e4c5d9da..d5eca21cc29 100644 --- a/utils/zerovec/src/zerovec/mod.rs +++ b/utils/zerovec/src/zerovec/mod.rs @@ -257,7 +257,9 @@ where /// `bytes` need to be an output from [`ZeroSlice::as_bytes()`]. pub const unsafe fn from_bytes_unchecked(bytes: &'a [u8]) -> Self { // &[u8] and &[T::ULE] are the same slice with different length metadata. - let (data, mut metadata): (usize, usize) = core::mem::transmute(bytes); + // n.b. be careful here, this might hit https://github.com/rust-lang/rust/issues/99923 + let data = bytes.as_ptr(); + let mut metadata = bytes.len(); metadata /= core::mem::size_of::(); Self::Borrowed(core::mem::transmute((data, metadata))) }