Skip to content

Commit 153de4c

Browse files
committed
std: Deprecate the copy_{,mut_}lifetime functions
Unsafe patterns such as `slice::from_raw_parts` and `CStr::from_ptr` have shown that dealing with lifetimes, while useful, is often a hindrance. Consequently these functions are rarely called today and are being deprecated.
1 parent 669d1cd commit 153de4c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libcore/mem.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,10 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
462462
#[unstable(feature = "copy_lifetime",
463463
reason = "this function may be removed in the future due to its \
464464
questionable utility")]
465+
#[deprecated(since = "1.2.0",
466+
reason = "unclear that this function buys more safety and \
467+
lifetimes are generally not handled as such in unsafe \
468+
code today")]
465469
pub unsafe fn copy_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S,
466470
ptr: &T) -> &'a T {
467471
transmute(ptr)
@@ -472,6 +476,10 @@ pub unsafe fn copy_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S,
472476
#[unstable(feature = "copy_lifetime",
473477
reason = "this function may be removed in the future due to its \
474478
questionable utility")]
479+
#[deprecated(since = "1.2.0",
480+
reason = "unclear that this function buys more safety and \
481+
lifetimes are generally not handled as such in unsafe \
482+
code today")]
475483
pub unsafe fn copy_mut_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S,
476484
ptr: &mut T)
477485
-> &'a mut T

0 commit comments

Comments
 (0)