Audit scoped re-erasure invariant
This commit is contained in:
@@ -52,7 +52,6 @@ impl<T> fmt::Debug for ContentGuard<'_, T> {
|
||||
|
||||
impl<'vec, T> ContentGuard<'vec, T> {
|
||||
pub(crate) fn new_scoped(erased: &'vec mut TypeErasedVec) -> Self {
|
||||
debug_assert!(!std::mem::needs_drop::<T>());
|
||||
Self {
|
||||
erased,
|
||||
reerase: TypeErasedVec::new_scoped,
|
||||
|
||||
+5
-2
@@ -76,8 +76,11 @@ impl TypeErasedVec {
|
||||
}
|
||||
|
||||
fn new_scoped<T>(vec: Vec<T>) -> Self {
|
||||
// `ContentGuard::new_scoped` is only constructed after
|
||||
// `try_as_type_scoped` has rejected types that need drop.
|
||||
debug_assert!(
|
||||
!std::mem::needs_drop::<T>(),
|
||||
"scoped element types must not require drop"
|
||||
);
|
||||
|
||||
Self {
|
||||
parts: VecParts::from_vec(vec),
|
||||
layout: Layout::new::<T>(),
|
||||
|
||||
Reference in New Issue
Block a user