expose drop_in_place as ptr::drop_in_place

This commit is contained in:
Alexis Beingessner 2015-07-21 14:11:50 -07:00 committed by Andrew Paseltiner
parent 914c4dbc2a
commit e72c226bed
3 changed files with 24 additions and 1 deletions

View File

@ -103,6 +103,8 @@
#![feature(unsize)]
#![feature(core_slice_ext)]
#![feature(core_str_ext)]
#![feature(drop_in_place)]
#![cfg_attr(stage0, feature(alloc_system))]
#![cfg_attr(not(stage0), feature(needs_allocator))]

View File

@ -195,7 +195,26 @@
pub fn size_of_val<T: ?Sized>(_: &T) -> usize;
pub fn min_align_of_val<T: ?Sized>(_: &T) -> usize;
pub fn drop_in_place<T: ?Sized>(_: *mut T);
/// Executes the destructor (if any) of the pointed-to value.
///
/// This has two usecases:
///
/// * It is *required* to use `drop_in_place` to drop unsized types like
/// trait objects, because they can't be read out onto the stack and
/// dropped normally.
///
/// * It is friendlier to the optimizer to do this over `ptr::read` when
/// dropping manually allocated memory (e.g. when writing Box/Rc/Vec),
/// as the compiler doesn't need to prove that it's sound to elide the
/// copy.
///
/// # Undefined Behaviour
///
/// This has all the same safety problems as `ptr::read` with respect to
/// invalid pointers, types, and double drops.
#[unstable(feature = "drop_in_place", reason = "just exposed, needs FCP", issue = "27908")]
pub fn drop_in_place<T: ?Sized>(to_drop: *mut T);
/// Gets a static string slice containing the name of a type.
pub fn type_name<T: ?Sized>() -> &'static str;

View File

@ -40,6 +40,8 @@
#[stable(feature = "rust1", since = "1.0.0")]
pub use intrinsics::write_bytes;
pub use intrinsics::drop_in_place;
/// Creates a null raw pointer.
///
/// # Examples