Skip to content

Commit

Permalink
std: Stabilize manually_drop feature
Browse files Browse the repository at this point in the history
Stabilizes

* `core::mem::ManuallyDrop`
* `std::mem::ManuallyDrop`
* `ManuallyDrop::new`
* `ManuallyDrop::into_inner`
* `ManuallyDrop::drop`
* `Deref for ManuallyDrop`
* `DerefMut for ManuallyDrop`

Closes #40673
  • Loading branch information
alexcrichton committed Jul 25, 2017
1 parent 3fae481 commit daeb607
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
#![feature(i128_type)]
#![feature(inclusive_range)]
#![feature(lang_items)]
#![feature(manually_drop)]
#![feature(needs_allocator)]
#![feature(nonzero)]
#![feature(offset_to)]
Expand Down
17 changes: 7 additions & 10 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,6 @@ pub fn discriminant<T>(v: &T) -> Discriminant<T> {
/// the type:
///
/// ```rust
/// # #![feature(manually_drop)]
/// use std::mem::ManuallyDrop;
/// struct Peach;
/// struct Banana;
Expand All @@ -864,7 +863,7 @@ pub fn discriminant<T>(v: &T) -> Discriminant<T> {
/// }
/// }
/// ```
#[unstable(feature = "manually_drop", issue = "40673")]
#[stable(feature = "manually_drop", since = "1.20.0")]
#[allow(unions_with_drop_fields)]
pub union ManuallyDrop<T>{ value: T }

Expand All @@ -874,11 +873,10 @@ impl<T> ManuallyDrop<T> {
/// # Examples
///
/// ```rust
/// # #![feature(manually_drop)]
/// use std::mem::ManuallyDrop;
/// ManuallyDrop::new(Box::new(()));
/// ```
#[unstable(feature = "manually_drop", issue = "40673")]
#[stable(feature = "manually_drop", since = "1.20.0")]
#[inline]
pub fn new(value: T) -> ManuallyDrop<T> {
ManuallyDrop { value: value }
Expand All @@ -889,12 +887,11 @@ impl<T> ManuallyDrop<T> {
/// # Examples
///
/// ```rust
/// # #![feature(manually_drop)]
/// use std::mem::ManuallyDrop;
/// let x = ManuallyDrop::new(Box::new(()));
/// let _: Box<()> = ManuallyDrop::into_inner(x);
/// ```
#[unstable(feature = "manually_drop", issue = "40673")]
#[stable(feature = "manually_drop", since = "1.20.0")]
#[inline]
pub fn into_inner(slot: ManuallyDrop<T>) -> T {
unsafe {
Expand All @@ -909,14 +906,14 @@ impl<T> ManuallyDrop<T> {
/// This function runs the destructor of the contained value and thus the wrapped value
/// now represents uninitialized data. It is up to the user of this method to ensure the
/// uninitialized data is not actually used.
#[unstable(feature = "manually_drop", issue = "40673")]
#[stable(feature = "manually_drop", since = "1.20.0")]
#[inline]
pub unsafe fn drop(slot: &mut ManuallyDrop<T>) {
ptr::drop_in_place(&mut slot.value)
}
}

#[unstable(feature = "manually_drop", issue = "40673")]
#[stable(feature = "manually_drop", since = "1.20.0")]
impl<T> ::ops::Deref for ManuallyDrop<T> {
type Target = T;
#[inline]
Expand All @@ -927,7 +924,7 @@ impl<T> ::ops::Deref for ManuallyDrop<T> {
}
}

#[unstable(feature = "manually_drop", issue = "40673")]
#[stable(feature = "manually_drop", since = "1.20.0")]
impl<T> ::ops::DerefMut for ManuallyDrop<T> {
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target {
Expand All @@ -937,7 +934,7 @@ impl<T> ::ops::DerefMut for ManuallyDrop<T> {
}
}

#[unstable(feature = "manually_drop", issue = "40673")]
#[stable(feature = "manually_drop", since = "1.20.0")]
impl<T: ::fmt::Debug> ::fmt::Debug for ManuallyDrop<T> {
fn fmt(&self, fmt: &mut ::fmt::Formatter) -> ::fmt::Result {
unsafe {
Expand Down
1 change: 0 additions & 1 deletion src/librustc_data_structures/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#![feature(conservative_impl_trait)]
#![feature(discriminant_value)]
#![feature(specialization)]
#![feature(manually_drop)]

#![cfg_attr(stage0, feature(associated_consts))]
#![cfg_attr(stage0, feature(struct_field_attributes))]
Expand Down

0 comments on commit daeb607

Please sign in to comment.