File tree 2 files changed +4
-0
lines changed
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]> {
441
441
#[ unstable( feature = "new_uninit" , issue = "63291" ) ]
442
442
pub fn new_uninit_slice ( len : usize ) -> Rc < [ mem:: MaybeUninit < T > ] > {
443
443
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`.
444
446
let ( layout, offset) = Layout :: new :: < RcBox < ( ) > > ( ) . extend ( data_layout) . unwrap ( ) ;
445
447
unsafe {
446
448
let allocated_ptr = Global . alloc ( layout)
Original file line number Diff line number Diff line change @@ -425,6 +425,8 @@ impl<T> Arc<[T]> {
425
425
#[ unstable( feature = "new_uninit" , issue = "63291" ) ]
426
426
pub fn new_uninit_slice ( len : usize ) -> Arc < [ mem:: MaybeUninit < T > ] > {
427
427
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`.
428
430
let ( layout, offset) = Layout :: new :: < ArcInner < ( ) > > ( ) . extend ( data_layout) . unwrap ( ) ;
429
431
unsafe {
430
432
let allocated_ptr = Global . alloc ( layout)
You can’t perform that action at this time.
0 commit comments