Skip to content

Commit e78b4da

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 e78b4da

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib.rs

+3-4
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;
@@ -270,7 +269,7 @@ impl<'a, T: 'a> Drop for Drain<'a,T> {
270269
#[cfg(feature = "union")]
271270
#[allow(unions_with_drop_fields)]
272271
union SmallVecData<A: Array> {
273-
inline: A,
272+
inline: ManuallyDrop<A>,
274273
heap: (*mut A::Item, usize),
275274
}
276275

@@ -286,10 +285,10 @@ impl<A: Array> SmallVecData<A> {
286285
}
287286
#[inline]
288287
fn from_inline(inline: A) -> SmallVecData<A> {
289-
SmallVecData { inline }
288+
SmallVecData { inline: ManuallyDrop::new(inline) }
290289
}
291290
#[inline]
292-
unsafe fn into_inline(self) -> A { self.inline }
291+
unsafe fn into_inline(self) -> A { ManuallyDrop::into_inner(self.inline) }
293292
#[inline]
294293
unsafe fn heap(&self) -> (*mut A::Item, usize) {
295294
self.heap

0 commit comments

Comments
 (0)