Skip to content

Commit 731cd26

Browse files
committed
Fix a layout miscalculation in alloc::RawVec
1 parent 6b20506 commit 731cd26

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

library/alloc/src/raw_vec.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,7 @@ impl<T, A: Allocator> RawVec<T, A> {
260260
// We have an allocated chunk of memory, so we can bypass runtime
261261
// checks to get our current layout.
262262
unsafe {
263-
let align = mem::align_of::<T>();
264-
let size = mem::size_of::<T>() * self.cap;
265-
let layout = Layout::from_size_align_unchecked(size, align);
263+
let layout = Layout::array::<T>(self.cap).unwrap_unchecked();
266264
Some((self.ptr.cast().into(), layout))
267265
}
268266
}

0 commit comments

Comments
 (0)