std: Second-pass stabilization of mem

This commit takes a second pass through the `std::mem` module for stabilization.
The only remaining non-stable items in this module were `forget`, `transmute`,
`copy_lifetime`, and `copy_lifetime_mut`.

The `forget` and `transmute` intrinsics themselves were marked `#[stable]` to
propgate into the `core::mem` module so they would be marked stable.

The `copy_lifetime` functions were left `unstable`, but `Sized?` annotations
were added to the parameters to allow more general use with DSTs.

The `size_of_val`, `min_align_of_val`, and `align_of_val` functions would like
to grow `Sized?` bounds, but this is a backwards compatible change that
currently ICEs the compiler, so this change was not made at this time.

Finally, the module itself was declared `#![stable]` in this pass.
This commit is contained in:
Alex Crichton 2014-12-15 19:40:25 -08:00
parent 0669a432a2
commit 23bae856b7
2 changed files with 11 additions and 3 deletions

View file

@ -217,6 +217,7 @@ extern "rust-intrinsic" {
///
/// `forget` is unsafe because the caller is responsible for
/// ensuring the argument is deallocated already.
#[stable]
pub fn forget<T>(_: T) -> ();
/// Unsafely transforms a value of one type into a value of another type.
@ -232,6 +233,7 @@ extern "rust-intrinsic" {
/// let v: &[u8] = unsafe { mem::transmute("L") };
/// assert!(v == [76u8]);
/// ```
#[stable]
pub fn transmute<T,U>(e: T) -> U;
/// Gives the address for the return value of the enclosing function.

View file

@ -13,9 +13,13 @@
//! This module contains functions for querying the size and alignment of
//! types, initializing and manipulating memory.
#![stable]
use kinds::Sized;
use intrinsics;
use ptr;
#[stable]
pub use intrinsics::transmute;
/// Moves a thing into the void.
@ -223,7 +227,8 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
#[inline]
#[unstable = "this function may be removed in the future due to its \
questionable utility"]
pub unsafe fn copy_lifetime<'a, S, T:'a>(_ptr: &'a S, ptr: &T) -> &'a T {
pub unsafe fn copy_lifetime<'a, Sized? S, Sized? T: 'a>(_ptr: &'a S,
ptr: &T) -> &'a T {
transmute(ptr)
}
@ -231,7 +236,8 @@ pub unsafe fn copy_lifetime<'a, S, T:'a>(_ptr: &'a S, ptr: &T) -> &'a T {
#[inline]
#[unstable = "this function may be removed in the future due to its \
questionable utility"]
pub unsafe fn copy_mut_lifetime<'a, S, T:'a>(_ptr: &'a mut S,
ptr: &mut T) -> &'a mut T {
pub unsafe fn copy_mut_lifetime<'a, Sized? S, Sized? T: 'a>(_ptr: &'a mut S,
ptr: &mut T)
-> &'a mut T {
transmute(ptr)
}