about summary refs log tree commit diff
path: root/src/liballoc/sync.rs
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2019-08-05 17:50:44 +0200
committerSimon Sapin <simon.sapin@exyr.org>2019-08-16 17:11:18 +0200
commitae1e201a0cd37a48bd3dabf1c643ccd5f53f7680 (patch)
tree48d1d3b2e6dd88c8720547c5113d2d98158047d1 /src/liballoc/sync.rs
parent78264f5e3c94592ff64aab831499f48497083a91 (diff)
downloadrust-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.rs2
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)