@@ -92,8 +92,8 @@ pub(crate) mod hack {
9292 // We shouldn't add inline attribute to this since this is used in
9393 // `vec!` macro mostly and causes perf regression. See #71204 for
9494 // discussion and perf results.
95- pub fn into_vec < T , A : Allocator > ( b : Box < [ T ] , A > ) -> Vec < T , A >
96- where [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
95+ pub fn into_vec < T , A : Allocator , const COOP_PREFERRED : bool > ( b : Box < [ T ] , A > ) -> Vec < T , A , COOP_PREFERRED >
96+ where [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : {
9797 unsafe {
9898 let len = b. len ( ) ;
9999 let ( b, alloc) = Box :: into_raw_with_allocator ( b) ;
@@ -103,31 +103,31 @@ pub(crate) mod hack {
103103
104104 #[ cfg( not( no_global_oom_handling) ) ]
105105 #[ inline]
106- pub fn to_vec < T : ConvertVec , A : Allocator > ( s : & [ T ] , alloc : A ) -> Vec < T , A >
107- where [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
106+ pub fn to_vec < T : ConvertVec , A : Allocator , const COOP_PREFERRED : bool > ( s : & [ T ] , alloc : A ) -> Vec < T , A , COOP_PREFERRED >
107+ where [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : {
108108 T :: to_vec ( s, alloc)
109109 }
110110
111111 #[ cfg( not( no_global_oom_handling) ) ]
112112 pub trait ConvertVec {
113- fn to_vec < A : Allocator > ( s : & [ Self ] , alloc : A ) -> Vec < Self , A >
113+ fn to_vec < A : Allocator , const COOP_PREFERRED : bool > ( s : & [ Self ] , alloc : A ) -> Vec < Self , A , COOP_PREFERRED >
114114 where
115115 Self : Sized ,
116- [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : ;
116+ [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : ;
117117 }
118118
119119 #[ cfg( not( no_global_oom_handling) ) ]
120120 impl < T : Clone > ConvertVec for T {
121121 #[ inline]
122- default fn to_vec < A : Allocator > ( s : & [ Self ] , alloc : A ) -> Vec < Self , A >
123- where [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
124- struct DropGuard < ' a , T , A : Allocator >
125- where [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
126- vec : & ' a mut Vec < T , A > ,
122+ default fn to_vec < A : Allocator , const COOP_PREFERRED : bool > ( s : & [ Self ] , alloc : A ) -> Vec < Self , A , COOP_PREFERRED >
123+ where [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : {
124+ struct DropGuard < ' a , T , A : Allocator , const COOP_PREFERRED : bool >
125+ where [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : {
126+ vec : & ' a mut Vec < T , A , COOP_PREFERRED > ,
127127 num_init : usize ,
128128 }
129- impl < ' a , T , A : Allocator > Drop for DropGuard < ' a , T , A >
130- where [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
129+ impl < ' a , T , A : Allocator , const COOP_PREFERRED : bool > Drop for DropGuard < ' a , T , A , COOP_PREFERRED >
130+ where [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : {
131131 #[ inline]
132132 fn drop ( & mut self ) {
133133 // SAFETY:
@@ -159,8 +159,8 @@ pub(crate) mod hack {
159159 #[ cfg( not( no_global_oom_handling) ) ]
160160 impl < T : Copy > ConvertVec for T {
161161 #[ inline]
162- fn to_vec < A : Allocator > ( s : & [ Self ] , alloc : A ) -> Vec < Self , A >
163- where [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
162+ fn to_vec < A : Allocator , const COOP_PREFERRED : bool > ( s : & [ Self ] , alloc : A ) -> Vec < Self , A , COOP_PREFERRED >
163+ where [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : {
164164 let mut v = Vec :: with_capacity_in ( s. len ( ) , alloc) ;
165165 // SAFETY:
166166 // allocated above with the capacity of `s`, and initialize to `s.len()` in
0 commit comments