@@ -778,7 +778,10 @@ where
778
778
// #[unstable(feature = "new_uninit", issue = "63291")]
779
779
#[ must_use]
780
780
#[ 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
+ {
782
785
unsafe {
783
786
RawVec :: < T , A , { SHORT_TERM_VEC_PREFERS_COOP ! ( ) } > :: with_capacity_in ( len, alloc)
784
787
. into_box ( len)
@@ -810,7 +813,10 @@ where
810
813
// #[unstable(feature = "new_uninit", issue = "63291")]
811
814
#[ must_use]
812
815
#[ 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
+ {
814
820
unsafe {
815
821
RawVec :: < T , A , { SHORT_TERM_VEC_PREFERS_COOP ! ( ) } > :: with_capacity_zeroed_in (
816
822
len, alloc,
@@ -1521,7 +1527,8 @@ impl<T: Copy> From<&[T]> for Box<[T]> {
1521
1527
/// ```
1522
1528
fn from ( slice : & [ T ] ) -> Box < [ T ] > {
1523
1529
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) ;
1525
1532
unsafe {
1526
1533
ptr:: copy_nonoverlapping ( slice. as_ptr ( ) , buf. ptr ( ) , len) ;
1527
1534
buf. into_box ( slice. len ( ) ) . assume_init ( )
@@ -2050,11 +2057,12 @@ impl<I> FromIterator<I> for Box<[I]> {
2050
2057
#[ stable( feature = "box_slice_clone" , since = "1.3.0" ) ]
2051
2058
impl < T : Clone , A : Allocator + Clone > Clone for Box < [ T ] , A >
2052
2059
where
2053
- [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : ,
2060
+ [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( false ) ] : ,
2054
2061
{
2055
2062
fn clone ( & self ) -> Self {
2056
2063
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 ( )
2058
2066
}
2059
2067
2060
2068
fn clone_from ( & mut self , other : & Self ) {
0 commit comments