diff options
| author | Benoît du Garreau <bdgdlm@outlook.com> | 2021-03-31 17:04:14 +0200 |
|---|---|---|
| committer | Benoît du Garreau <bdgdlm@outlook.com> | 2022-02-12 11:40:59 +0100 |
| commit | 6027182328c341e672b58c820777941814643a3b (patch) | |
| tree | 62ac97f66915570ab64ecaed4ba3269208182e59 | |
| parent | 9cdefd763b910ffd1d42233a8c752ab5fd84ca4d (diff) | |
| download | rust-6027182328c341e672b58c820777941814643a3b.tar.gz rust-6027182328c341e672b58c820777941814643a3b.zip | |
Fix a layout miscalculation in alloc::RawVec
| -rw-r--r-- | library/alloc/src/raw_vec.rs | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/library/alloc/src/raw_vec.rs b/library/alloc/src/raw_vec.rs index 8fa0242ca9a..0edcaa9ef76 100644 --- a/library/alloc/src/raw_vec.rs +++ b/library/alloc/src/raw_vec.rs @@ -244,9 +244,7 @@ impl<T, A: Allocator> RawVec<T, A> { // We have an allocated chunk of memory, so we can bypass runtime // checks to get our current layout. unsafe { - let align = mem::align_of::<T>(); - let size = mem::size_of::<T>() * self.cap; - let layout = Layout::from_size_align_unchecked(size, align); + let layout = Layout::array::<T>(self.cap).unwrap_unchecked(); Some((self.ptr.cast().into(), layout)) } } |
