Skip to content

Commit f507dc3

Browse files
committed
Remove some unneeded casts
1 parent 2b4856e commit f507dc3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/liballoc/raw_vec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl<T, A: Alloc> RawVec<T, A> {
9393

9494
// handles ZSTs and `cap = 0` alike
9595
let ptr = if alloc_size == 0 {
96-
NonNull::<T>::dangling().cast()
96+
NonNull::<T>::dangling()
9797
} else {
9898
let align = mem::align_of::<T>();
9999
let layout = Layout::from_size_align(alloc_size, align).unwrap();
@@ -103,13 +103,13 @@ impl<T, A: Alloc> RawVec<T, A> {
103103
a.alloc(layout)
104104
};
105105
match result {
106-
Ok(ptr) => ptr,
106+
Ok(ptr) => ptr.cast(),
107107
Err(_) => oom(layout),
108108
}
109109
};
110110

111111
RawVec {
112-
ptr: ptr.cast().into(),
112+
ptr: ptr.into(),
113113
cap,
114114
a,
115115
}

src/test/run-pass/realloc-16687.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ unsafe fn test_triangle() -> bool {
6464
println!("deallocate({:?}, {:?}", ptr, layout);
6565
}
6666

67-
Global.dealloc(NonNull::new_unchecked(ptr).cast(), layout);
67+
Global.dealloc(NonNull::new_unchecked(ptr), layout);
6868
}
6969

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

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

7878
if PRINT {

0 commit comments

Comments
 (0)