@@ -778,7 +778,10 @@ where
778778 // #[unstable(feature = "new_uninit", issue = "63291")]
779779 #[ must_use]
780780 #[ allow( unused_braces) ]
781- pub fn new_uninit_slice_in ( len : usize , alloc : A ) -> Box < [ mem:: MaybeUninit < T > ] , A > {
781+ pub fn new_uninit_slice_in ( len : usize , alloc : A ) -> Box < [ mem:: MaybeUninit < T > ] , A >
782+ where
783+ [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( SHORT_TERM_VEC_PREFERS_COOP ! ( ) ) ] : ,
784+ {
782785 unsafe {
783786 RawVec :: < T , A , { SHORT_TERM_VEC_PREFERS_COOP ! ( ) } > :: with_capacity_in ( len, alloc)
784787 . into_box ( len)
@@ -810,7 +813,10 @@ where
810813 // #[unstable(feature = "new_uninit", issue = "63291")]
811814 #[ must_use]
812815 #[ allow( unused_braces) ]
813- pub fn new_zeroed_slice_in ( len : usize , alloc : A ) -> Box < [ mem:: MaybeUninit < T > ] , A > {
816+ pub fn new_zeroed_slice_in ( len : usize , alloc : A ) -> Box < [ mem:: MaybeUninit < T > ] , A >
817+ where
818+ [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( SHORT_TERM_VEC_PREFERS_COOP ! ( ) ) ] : ,
819+ {
814820 unsafe {
815821 RawVec :: < T , A , { SHORT_TERM_VEC_PREFERS_COOP ! ( ) } > :: with_capacity_zeroed_in (
816822 len, alloc,
@@ -1521,7 +1527,8 @@ impl<T: Copy> From<&[T]> for Box<[T]> {
15211527 /// ```
15221528 fn from ( slice : & [ T ] ) -> Box < [ T ] > {
15231529 let len = slice. len ( ) ;
1524- let buf = RawVec :: with_capacity ( len) ;
1530+ // false = no need for co-alloc metadata, since it would get lost once converted to Box.
1531+ let buf = RawVec :: < T , Global , false > :: with_capacity ( len) ;
15251532 unsafe {
15261533 ptr:: copy_nonoverlapping ( slice. as_ptr ( ) , buf. ptr ( ) , len) ;
15271534 buf. into_box ( slice. len ( ) ) . assume_init ( )
@@ -2050,11 +2057,12 @@ impl<I> FromIterator<I> for Box<[I]> {
20502057#[ stable( feature = "box_slice_clone" , since = "1.3.0" ) ]
20512058impl < T : Clone , A : Allocator + Clone > Clone for Box < [ T ] , A >
20522059where
2053- [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : ,
2060+ [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( false ) ] : ,
20542061{
20552062 fn clone ( & self ) -> Self {
20562063 let alloc = Box :: allocator ( self ) . clone ( ) ;
2057- self . to_vec_in ( alloc) . into_boxed_slice ( )
2064+ // false = no need for co-alloc metadata, since it would get lost once converted to the boxed slice.
2065+ self . to_vec_in :: < A , false > ( alloc) . into_boxed_slice ( )
20582066 }
20592067
20602068 fn clone_from ( & mut self , other : & Self ) {
0 commit comments