Skip to content

Commit 6027182

Browse files
committed
Fix a layout miscalculation in alloc::RawVec
1 parent 9cdefd7 commit 6027182

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

library/alloc/src/raw_vec.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,7 @@ impl<T, A: Allocator> RawVec<T, A> {
244244
// We have an allocated chunk of memory, so we can bypass runtime
245245
// checks to get our current layout.
246246
unsafe {
247-
let align = mem::align_of::<T>();
248-
let size = mem::size_of::<T>() * self.cap;
249-
let layout = Layout::from_size_align_unchecked(size, align);
247+
let layout = Layout::array::<T>(self.cap).unwrap_unchecked();
250248
Some((self.ptr.cast().into(), layout))
251249
}
252250
}

0 commit comments

Comments
 (0)