Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::ptr::read_ptr now takes *T instead of *mut T #10595

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libstd/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub unsafe fn replace_ptr<T>(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<T>(src: *mut T) -> T {
pub unsafe fn read_ptr<T>(src: *T) -> T {
let mut tmp: T = intrinsics::uninit();
copy_nonoverlapping_memory(&mut tmp, src, 1);
tmp
Expand All @@ -168,7 +168,7 @@ pub unsafe fn read_ptr<T>(src: *mut T) -> T {
#[inline(always)]
pub unsafe fn read_and_zero_ptr<T>(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);
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,7 @@ impl<T> OwnedVector<T> 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))
}
}
}
Expand Down