From 023a931309c17dab1b9d2332369626a26a5227cc Mon Sep 17 00:00:00 2001 From: Mikhail Zabaluev Date: Thu, 5 Feb 2015 22:19:11 +0200 Subject: [PATCH] Make the lifetime anchor immutable on std::mem::copy_mut_lifetime Only the second reference's mutability is relevant to the mutability of the returned reference. --- src/libcore/mem.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 0d26c8e79142..51bf3c1648f5 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -331,8 +331,9 @@ pub unsafe fn copy_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S, #[unstable(feature = "core", reason = "this function may be removed in the future due to its \ questionable utility")] -pub unsafe fn copy_mut_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a mut S, - ptr: &mut T) - -> &'a mut T { +pub unsafe fn copy_mut_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S, + ptr: &mut T) + -> &'a mut T +{ transmute(ptr) }