From 248cb90dfa00a7efdd51eb457afd9b59246b2d24 Mon Sep 17 00:00:00 2001 From: Ziad Hatahet Date: Thu, 21 Nov 2013 11:31:58 -0800 Subject: [PATCH] `std::ptr::read_ptr` now takes `*T` instead of `*mut T` Closes #10579 --- src/libstd/ptr.rs | 4 ++-- src/libstd/vec.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libstd/ptr.rs b/src/libstd/ptr.rs index 887f7f2e9a6..9f60c3a32b2 100644 --- a/src/libstd/ptr.rs +++ b/src/libstd/ptr.rs @@ -155,7 +155,7 @@ pub unsafe fn replace_ptr(dest: *mut T, mut src: T) -> T { * Reads the value from `*src` and returns it. Does not copy `*src`. */ #[inline(always)] -pub unsafe fn read_ptr(src: *mut T) -> T { +pub unsafe fn read_ptr(src: *T) -> T { let mut tmp: T = intrinsics::uninit(); copy_nonoverlapping_memory(&mut tmp, src, 1); tmp @@ -168,7 +168,7 @@ pub unsafe fn read_ptr(src: *mut T) -> T { #[inline(always)] pub unsafe fn read_and_zero_ptr(dest: *mut T) -> T { // Copy the data out from `dest`: - let tmp = read_ptr(dest); + let tmp = read_ptr(&*dest); // Now zero out `dest`: zero_memory(dest, 1); diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 2bd6a00ed4a..079d8adae58 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -1527,7 +1527,7 @@ impl OwnedVector for ~[T] { let valptr = ptr::to_mut_unsafe_ptr(&mut self[ln - 1u]); unsafe { raw::set_len(self, ln - 1u); - Some(ptr::read_ptr(valptr)) + Some(ptr::read_ptr(&*valptr)) } } }