Skip to content

Commit d6bfa84

Browse files
committed
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.
1 parent e244d0a commit d6bfa84

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ use std::fmt;
6060
use std::hash::{Hash, Hasher};
6161
use std::iter::{IntoIterator, FromIterator, repeat};
6262
use std::mem;
63-
#[cfg(not(feature = "union"))]
6463
use std::mem::ManuallyDrop;
6564
use std::ops;
6665
use std::ptr;
@@ -268,9 +267,8 @@ impl<'a, T: 'a> Drop for Drain<'a,T> {
268267
}
269268

270269
#[cfg(feature = "union")]
271-
#[allow(unions_with_drop_fields)]
272270
union SmallVecData<A: Array> {
273-
inline: A,
271+
inline: ManuallyDrop<A>,
274272
heap: (*mut A::Item, usize),
275273
}
276274

@@ -286,10 +284,10 @@ impl<A: Array> SmallVecData<A> {
286284
}
287285
#[inline]
288286
fn from_inline(inline: A) -> SmallVecData<A> {
289-
SmallVecData { inline }
287+
SmallVecData { inline: ManuallyDrop::new(inline) }
290288
}
291289
#[inline]
292-
unsafe fn into_inline(self) -> A { self.inline }
290+
unsafe fn into_inline(self) -> A { ManuallyDrop::into_inner(self.inline) }
293291
#[inline]
294292
unsafe fn heap(&self) -> (*mut A::Item, usize) {
295293
self.heap

0 commit comments

Comments
 (0)