From 9db832d4a4c9c12d15bf631a2622820f7db7c574 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sun, 3 Oct 2021 20:59:49 -0700 Subject: [PATCH] review comments --- utils/zerovec/src/ule/mod.rs | 2 ++ utils/zerovec/src/yoke_impls.rs | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/zerovec/src/ule/mod.rs b/utils/zerovec/src/ule/mod.rs index b2dbed041b9..0340884f017 100644 --- a/utils/zerovec/src/ule/mod.rs +++ b/utils/zerovec/src/ule/mod.rs @@ -13,6 +13,7 @@ mod vec; pub use chars::CharULE; pub use plain::PlainOldULE; +use alloc::alloc::Layout; use alloc::borrow::ToOwned; use alloc::boxed::Box; use core::{fmt, mem, slice}; @@ -311,6 +312,7 @@ pub unsafe trait VarULE: 'static { // Get the pointer representation let ptr: *mut Self = Self::from_byte_slice_unchecked(&bytesvec) as *const Self as *mut Self; + assert_eq!(Layout::for_value(&*ptr), Layout::for_value(&*bytesvec)); // Forget the allocation mem::forget(bytesvec); // Transmute the pointer to an owned pointer diff --git a/utils/zerovec/src/yoke_impls.rs b/utils/zerovec/src/yoke_impls.rs index 29967acadda..23523908f6c 100644 --- a/utils/zerovec/src/yoke_impls.rs +++ b/utils/zerovec/src/yoke_impls.rs @@ -107,8 +107,6 @@ impl<'a, T: 'static + AsULE + ?Sized> ZeroCopyFrom> for ZeroVec<' impl<'a, T: 'static + VarULE + ?Sized> ZeroCopyFrom> for VarZeroVec<'static, T> { fn zero_copy_from<'b>(cart: &'b VarZeroVec<'a, T>) -> VarZeroVec<'b, T> { - // the owned variant is not compatible with the borrowed one - // clones are shallow for the borrowed variant anyway cart.as_borrowed() } }