Skip to content

Commit 73a8953

Browse files
authored
Auto merge of #248 - saethlin:master, r=mbrubeck
Wrap with ManuallyDrop so that the union feature works on 1.50 Per #247 (comment) The unrelated diff was produced by rustfmt, which my editor runs automatically. I'm a bit surprised, usually when this produces a diff it's a big one. Do you want me to revert those lines?
2 parents f5f1a22 + 2785548 commit 73a8953

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/lib.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
//!
2929
//! ### `union`
3030
//!
31-
//! **This feature is unstable and requires a nightly build of the Rust toolchain.**
31+
//! **This feature requires Rust 1.50.**
3232
//!
3333
//! When the `union` feature is enabled `smallvec` will track its state (inline or spilled)
3434
//! without the use of an enum tag, reducing the size of the `smallvec` by one machine word.
@@ -37,7 +37,7 @@
3737
//! machine words.
3838
//!
3939
//! To use this feature add `features = ["union"]` in the `smallvec` section of Cargo.toml.
40-
//! Note that this feature requires a nightly compiler (for now).
40+
//! Note that this feature requires Rust 1.50.
4141
//!
4242
//! Tracking issue: [rust-lang/rust#55149](https://github.com/rust-lang/rust/issues/55149)
4343
//!
@@ -71,7 +71,6 @@
7171
//! Tracking issue: [rust-lang/rust#34761](https://github.com/rust-lang/rust/issues/34761)
7272
7373
#![no_std]
74-
#![cfg_attr(feature = "union", feature(untagged_unions))]
7574
#![cfg_attr(feature = "specialization", allow(incomplete_features))]
7675
#![cfg_attr(feature = "specialization", feature(specialization))]
7776
#![cfg_attr(feature = "may_dangle", feature(dropck_eyepatch))]
@@ -352,7 +351,7 @@ impl<'a, T: 'a + Array> Drop for Drain<'a, T> {
352351

353352
#[cfg(feature = "union")]
354353
union SmallVecData<A: Array> {
355-
inline: MaybeUninit<A>,
354+
inline: core::mem::ManuallyDrop<MaybeUninit<A>>,
356355
heap: (*mut A::Item, usize),
357356
}
358357

@@ -368,11 +367,13 @@ impl<A: Array> SmallVecData<A> {
368367
}
369368
#[inline]
370369
fn from_inline(inline: MaybeUninit<A>) -> SmallVecData<A> {
371-
SmallVecData { inline }
370+
SmallVecData {
371+
inline: core::mem::ManuallyDrop::new(inline),
372+
}
372373
}
373374
#[inline]
374375
unsafe fn into_inline(self) -> MaybeUninit<A> {
375-
self.inline
376+
core::mem::ManuallyDrop::into_inner(self.inline)
376377
}
377378
#[inline]
378379
unsafe fn heap(&self) -> (*mut A::Item, usize) {
@@ -793,7 +794,8 @@ impl<A: Array> SmallVec<A> {
793794
/// assert_eq!(*v1, []);
794795
/// ```
795796
pub fn append<B>(&mut self, other: &mut SmallVec<B>)
796-
where B: Array<Item = A::Item>
797+
where
798+
B: Array<Item = A::Item>,
797799
{
798800
self.extend(other.drain(..))
799801
}
@@ -1957,10 +1959,9 @@ macro_rules! impl_array(
19571959

19581960
#[cfg(not(feature = "const_generics"))]
19591961
impl_array!(
1960-
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1961-
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 36, 0x40, 0x60, 0x80,
1962-
0x100, 0x200, 0x400, 0x600, 0x800, 0x1000, 0x2000, 0x4000, 0x6000, 0x8000, 0x10000, 0x20000,
1963-
0x40000, 0x60000, 0x80000, 0x10_0000
1962+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
1963+
26, 27, 28, 29, 30, 31, 32, 36, 0x40, 0x60, 0x80, 0x100, 0x200, 0x400, 0x600, 0x800, 0x1000,
1964+
0x2000, 0x4000, 0x6000, 0x8000, 0x10000, 0x20000, 0x40000, 0x60000, 0x80000, 0x10_0000
19641965
);
19651966

19661967
/// Convenience trait for constructing a `SmallVec`

0 commit comments

Comments
 (0)