diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2019-08-05 17:50:44 +0200 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2019-08-16 17:11:18 +0200 |
| commit | ae1e201a0cd37a48bd3dabf1c643ccd5f53f7680 (patch) | |
| tree | 48d1d3b2e6dd88c8720547c5113d2d98158047d1 /src/liballoc/sync.rs | |
| parent | 78264f5e3c94592ff64aab831499f48497083a91 (diff) | |
| download | rust-ae1e201a0cd37a48bd3dabf1c643ccd5f53f7680.tar.gz rust-ae1e201a0cd37a48bd3dabf1c643ccd5f53f7680.zip | |
Add a comment on the usage of Layout::new::<RcBox<()>>()
Diffstat (limited to 'src/liballoc/sync.rs')
| -rw-r--r-- | src/liballoc/sync.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 50fd9850893..1bd177be0d5 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -425,6 +425,8 @@ impl<T> Arc<[T]> { #[unstable(feature = "new_uninit", issue = "63291")] pub fn new_uninit_slice(len: usize) -> Arc<[mem::MaybeUninit<T>]> { let data_layout = Layout::array::<mem::MaybeUninit<T>>(len).unwrap(); + // This relies on `value` being the last field of `RcBox` in memory, + // so that the layout of `RcBox<T>` is the same as that of `RcBox<()>` followed by `T`. let (layout, offset) = Layout::new::<ArcInner<()>>().extend(data_layout).unwrap(); unsafe { let allocated_ptr = Global.alloc(layout) |
