Skip to content

Commit

Permalink
Remove some unneeded casts
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Jun 11, 2018
1 parent 11f992c commit 0081d88
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/liballoc/raw_vec.rs
Expand Up @@ -93,7 +93,7 @@ impl<T, A: Alloc> RawVec<T, A> {

// handles ZSTs and `cap = 0` alike
let ptr = if alloc_size == 0 {
NonNull::<T>::dangling().cast()
NonNull::<T>::dangling()
} else {
let align = mem::align_of::<T>();
let layout = Layout::from_size_align(alloc_size, align).unwrap();
Expand All @@ -103,13 +103,13 @@ impl<T, A: Alloc> RawVec<T, A> {
a.alloc(layout)
};
match result {
Ok(ptr) => ptr,
Ok(ptr) => ptr.cast(),
Err(_) => oom(layout),
}
};

RawVec {
ptr: ptr.cast().into(),
ptr: ptr.into(),
cap,
a,
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/run-pass/realloc-16687.rs
Expand Up @@ -64,15 +64,15 @@ unsafe fn test_triangle() -> bool {
println!("deallocate({:?}, {:?}", ptr, layout);
}

Global.dealloc(NonNull::new_unchecked(ptr).cast(), layout);
Global.dealloc(NonNull::new_unchecked(ptr), layout);
}

unsafe fn reallocate(ptr: *mut u8, old: Layout, new: Layout) -> *mut u8 {
if PRINT {
println!("reallocate({:?}, old={:?}, new={:?})", ptr, old, new);
}

let ret = Global.realloc(NonNull::new_unchecked(ptr).cast(), old, new.size())
let ret = Global.realloc(NonNull::new_unchecked(ptr), old, new.size())
.unwrap_or_else(|_| oom(Layout::from_size_align_unchecked(new.size(), old.align())));

if PRINT {
Expand Down

0 comments on commit 0081d88

Please sign in to comment.