From d6bfa840b87fc9ea305572f94884e27c83f7bf5a Mon Sep 17 00:00:00 2001 From: bluss Date: Wed, 19 Dec 2018 22:08:58 +0100 Subject: [PATCH] Update union code to use ManuallyDrop A Rust breaking change to the untagged_unions feature, means that no union fields may have destructors, so we need use ManuallyDrop also around the inline union field. --- lib.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib.rs b/lib.rs index 74c4abf..c6642a6 100644 --- a/lib.rs +++ b/lib.rs @@ -60,7 +60,6 @@ use std::fmt; use std::hash::{Hash, Hasher}; use std::iter::{IntoIterator, FromIterator, repeat}; use std::mem; -#[cfg(not(feature = "union"))] use std::mem::ManuallyDrop; use std::ops; use std::ptr; @@ -268,9 +267,8 @@ impl<'a, T: 'a> Drop for Drain<'a,T> { } #[cfg(feature = "union")] -#[allow(unions_with_drop_fields)] union SmallVecData { - inline: A, + inline: ManuallyDrop, heap: (*mut A::Item, usize), } @@ -286,10 +284,10 @@ impl SmallVecData { } #[inline] fn from_inline(inline: A) -> SmallVecData { - SmallVecData { inline } + SmallVecData { inline: ManuallyDrop::new(inline) } } #[inline] - unsafe fn into_inline(self) -> A { self.inline } + unsafe fn into_inline(self) -> A { ManuallyDrop::into_inner(self.inline) } #[inline] unsafe fn heap(&self) -> (*mut A::Item, usize) { self.heap