Skip to content

Commit fc2ce7c

Browse files
authored
Rollup merge of #73459 - cuviper:into_boxed_slice-unicast, r=dtolnay
Reduce pointer casts in Box::into_boxed_slice We only need to cast the pointer once to change `Box<T>` to an array `Box<[T; 1]>`, then we can let unsized coercion return `Box<[T]>`.
2 parents 7d3238f + a7c2cf8 commit fc2ce7c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/liballoc/boxed.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ impl<T> Box<T> {
248248
#[unstable(feature = "box_into_boxed_slice", issue = "71582")]
249249
pub fn into_boxed_slice(boxed: Box<T>) -> Box<[T]> {
250250
// *mut T and *mut [T; 1] have the same size and alignment
251-
unsafe { Box::from_raw(Box::into_raw(boxed) as *mut [T; 1] as *mut [T]) }
251+
unsafe { Box::from_raw(Box::into_raw(boxed) as *mut [T; 1]) }
252252
}
253253
}
254254

0 commit comments

Comments
 (0)