Skip to content

Commit 23bae85

Browse files
committed
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.
1 parent 0669a43 commit 23bae85

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/libcore/intrinsics.rs

+2
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ extern "rust-intrinsic" {
217217
///
218218
/// `forget` is unsafe because the caller is responsible for
219219
/// ensuring the argument is deallocated already.
220+
#[stable]
220221
pub fn forget<T>(_: T) -> ();
221222

222223
/// Unsafely transforms a value of one type into a value of another type.
@@ -232,6 +233,7 @@ extern "rust-intrinsic" {
232233
/// let v: &[u8] = unsafe { mem::transmute("L") };
233234
/// assert!(v == [76u8]);
234235
/// ```
236+
#[stable]
235237
pub fn transmute<T,U>(e: T) -> U;
236238

237239
/// Gives the address for the return value of the enclosing function.

src/libcore/mem.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@
1313
//! This module contains functions for querying the size and alignment of
1414
//! types, initializing and manipulating memory.
1515
16+
#![stable]
17+
18+
use kinds::Sized;
1619
use intrinsics;
1720
use ptr;
1821

22+
#[stable]
1923
pub use intrinsics::transmute;
2024

2125
/// Moves a thing into the void.
@@ -223,15 +227,17 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
223227
#[inline]
224228
#[unstable = "this function may be removed in the future due to its \
225229
questionable utility"]
226-
pub unsafe fn copy_lifetime<'a, S, T:'a>(_ptr: &'a S, ptr: &T) -> &'a T {
230+
pub unsafe fn copy_lifetime<'a, Sized? S, Sized? T: 'a>(_ptr: &'a S,
231+
ptr: &T) -> &'a T {
227232
transmute(ptr)
228233
}
229234

230235
/// Transforms lifetime of the second mutable pointer to match the first.
231236
#[inline]
232237
#[unstable = "this function may be removed in the future due to its \
233238
questionable utility"]
234-
pub unsafe fn copy_mut_lifetime<'a, S, T:'a>(_ptr: &'a mut S,
235-
ptr: &mut T) -> &'a mut T {
239+
pub unsafe fn copy_mut_lifetime<'a, Sized? S, Sized? T: 'a>(_ptr: &'a mut S,
240+
ptr: &mut T)
241+
-> &'a mut T {
236242
transmute(ptr)
237243
}

0 commit comments

Comments
 (0)