1
Fork 0

Remove some unneeded casts

This commit is contained in:
Simon Sapin 2018-05-30 21:04:17 +02:00
parent 11f992c958
commit 0081d8826b
2 changed files with 5 additions and 5 deletions

View file

@ -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();
@ -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,
}

View file

@ -64,7 +64,7 @@ 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 {
@ -72,7 +72,7 @@ unsafe fn test_triangle() -> bool {
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 {