diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index 8768f1ff081c1..aeb7f90d3e60e 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -137,17 +137,16 @@ pub use hack::to_vec; // `core::slice::SliceExt` - we need to supply these functions for the // `test_permutations` test mod hack { - use core::mem; - use crate::boxed::Box; use crate::vec::Vec; #[cfg(test)] use crate::string::ToString; - pub fn into_vec(mut b: Box<[T]>) -> Vec { + pub fn into_vec(b: Box<[T]>) -> Vec { unsafe { - let xs = Vec::from_raw_parts(b.as_mut_ptr(), b.len(), b.len()); - mem::forget(b); + let len = b.len(); + let b = Box::into_raw(b); + let xs = Vec::from_raw_parts(b as *mut T, len, len); xs } }