mirror of
https://github.com/openharmony/third_party_rust_rust-smallvec.git
synced 2026-07-21 01:55:25 -04:00
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.
This commit is contained in:
@@ -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<A: Array> {
|
||||
inline: A,
|
||||
inline: ManuallyDrop<A>,
|
||||
heap: (*mut A::Item, usize),
|
||||
}
|
||||
|
||||
@@ -286,10 +284,10 @@ impl<A: Array> SmallVecData<A> {
|
||||
}
|
||||
#[inline]
|
||||
fn from_inline(inline: A) -> SmallVecData<A> {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user