File tree Expand file tree Collapse file tree 2 files changed +4
-0
lines changed
Expand file tree Collapse file tree 2 files changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -441,6 +441,8 @@ impl<T> Rc<[T]> {
441441 #[ unstable( feature = "new_uninit" , issue = "63291" ) ]
442442 pub fn new_uninit_slice ( len : usize ) -> Rc < [ mem:: MaybeUninit < T > ] > {
443443 let data_layout = Layout :: array :: < mem:: MaybeUninit < T > > ( len) . unwrap ( ) ;
444+ // This relies on `value` being the last field of `RcBox` in memory,
445+ // so that the layout of `RcBox<T>` is the same as that of `RcBox<()>` followed by `T`.
444446 let ( layout, offset) = Layout :: new :: < RcBox < ( ) > > ( ) . extend ( data_layout) . unwrap ( ) ;
445447 unsafe {
446448 let allocated_ptr = Global . alloc ( layout)
Original file line number Diff line number Diff line change @@ -425,6 +425,8 @@ impl<T> Arc<[T]> {
425425 #[ unstable( feature = "new_uninit" , issue = "63291" ) ]
426426 pub fn new_uninit_slice ( len : usize ) -> Arc < [ mem:: MaybeUninit < T > ] > {
427427 let data_layout = Layout :: array :: < mem:: MaybeUninit < T > > ( len) . unwrap ( ) ;
428+ // This relies on `value` being the last field of `RcBox` in memory,
429+ // so that the layout of `RcBox<T>` is the same as that of `RcBox<()>` followed by `T`.
428430 let ( layout, offset) = Layout :: new :: < ArcInner < ( ) > > ( ) . extend ( data_layout) . unwrap ( ) ;
429431 unsafe {
430432 let allocated_ptr = Global . alloc ( layout)
You can’t perform that action at this time.
0 commit comments