Skip to content

Commit f7f8539

Browse files
CoAlloc: Vec: Renamed ::core::alloc::co_alloc_metadata_num_slots_with_preference to ::core::alloc::co_alloc_metadata_num_slots_with_preference_specific. ICE
1 parent 2472386 commit f7f8539

File tree

11 files changed

+164
-122
lines changed

11 files changed

+164
-122
lines changed

library/alloc/src/raw_vec.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub(crate) struct RawVec<
5555
A: Allocator = Global,
5656
const COOP_PREFERRED: bool = DEFAULT_COOP_PREFERRED,
5757
> where
58-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
58+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
5959
{
6060
ptr: Unique<T>,
6161
cap: usize,
@@ -64,7 +64,7 @@ pub(crate) struct RawVec<
6464
//pub(crate) meta: [GlobalCoAllocMeta; {if core::any::TypeId::of::<A>()==core::any::TypeId::of::<Global>() {1} else {0}}],
6565
//pub(crate) meta: [GlobalCoAllocMeta; mem::size_of::<A::IsCoAllocator>()],
6666
pub(crate) metas: [GlobalCoAllocMeta;
67-
alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)],
67+
alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)],
6868
}
6969

7070
impl<T, const COOP_PREFERRED: bool> RawVec<T, Global, COOP_PREFERRED>
@@ -119,7 +119,7 @@ where
119119

120120
impl<T, A: Allocator, const COOP_PREFERRED: bool> RawVec<T, A, COOP_PREFERRED>
121121
where
122-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
122+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
123123
{
124124
// Tiny Vecs are dumb. Skip to:
125125
// - 8 if the element size is 1, because any heap allocators is likely
@@ -143,7 +143,7 @@ where
143143
cap: 0,
144144
alloc,
145145
metas: [GlobalCoAllocMeta {/*one: 1*/ /* , two: 2, three: 3, four: 4*/};
146-
alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)],
146+
alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)],
147147
}
148148
}
149149

@@ -222,7 +222,9 @@ where
222222
cap: capacity,
223223
alloc,
224224
metas: [GlobalCoAllocMeta {/*one: 1*/ /*, two: 2, three: 3, four: 4*/};
225-
alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)],
225+
alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(
226+
COOP_PREFERRED,
227+
)],
226228
}
227229
}
228230
}
@@ -244,7 +246,7 @@ where
244246
cap: capacity,
245247
alloc,
246248
metas: [GlobalCoAllocMeta {/*one: 1*/ /*, two: 2, three: 3, four: 4*/};
247-
alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)],
249+
alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)],
248250
}
249251
}
250252

@@ -314,7 +316,7 @@ where
314316
len: usize,
315317
additional: usize,
316318
) where
317-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
319+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
318320
{
319321
handle_reserve(slf.grow_amortized(len, additional));
320322
}
@@ -390,7 +392,7 @@ where
390392

391393
impl<T, A: Allocator, const COOP_PREFERRED: bool> RawVec<T, A, COOP_PREFERRED>
392394
where
393-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
395+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
394396
{
395397
/// Returns if the buffer needs to grow to fulfill the needed extra capacity.
396398
/// Mainly used to make inlining reserve-calls possible without inlining `grow`.
@@ -512,7 +514,7 @@ where
512514
unsafe impl<#[may_dangle] T, A: Allocator, const COOP_PREFERRED: bool> Drop
513515
for RawVec<T, A, COOP_PREFERRED>
514516
where
515-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
517+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
516518
{
517519
/// Frees the memory owned by the `RawVec` *without* trying to drop its contents.
518520
default fn drop(&mut self) {

library/alloc/src/slice.rs

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ pub(crate) mod hack {
101101
b: Box<[T], A>,
102102
) -> Vec<T, A, COOP_PREFERRED>
103103
where
104-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
104+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(
105+
COOP_PREFERRED,
106+
)]:,
105107
{
106108
unsafe {
107109
let len = b.len();
@@ -117,7 +119,9 @@ pub(crate) mod hack {
117119
alloc: A,
118120
) -> Vec<T, A, COOP_PREFERRED>
119121
where
120-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
122+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(
123+
COOP_PREFERRED,
124+
)]:,
121125
{
122126
T::to_vec(s, alloc)
123127
}
@@ -130,7 +134,9 @@ pub(crate) mod hack {
130134
) -> Vec<Self, A, COOP_PREFERRED>
131135
where
132136
Self: Sized,
133-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:;
137+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(
138+
COOP_PREFERRED,
139+
)]:;
134140
}
135141

136142
#[cfg(not(no_global_oom_handling))]
@@ -141,18 +147,24 @@ pub(crate) mod hack {
141147
alloc: A,
142148
) -> Vec<Self, A, COOP_PREFERRED>
143149
where
144-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
150+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(
151+
COOP_PREFERRED,
152+
)]:,
145153
{
146154
struct DropGuard<'a, T, A: Allocator, const COOP_PREFERRED: bool>
147155
where
148-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
156+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(
157+
COOP_PREFERRED,
158+
)]:,
149159
{
150160
vec: &'a mut Vec<T, A, COOP_PREFERRED>,
151161
num_init: usize,
152162
}
153163
impl<'a, T, A: Allocator, const COOP_PREFERRED: bool> Drop for DropGuard<'a, T, A, COOP_PREFERRED>
154164
where
155-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
165+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(
166+
COOP_PREFERRED,
167+
)]:,
156168
{
157169
#[inline]
158170
fn drop(&mut self) {
@@ -190,7 +202,9 @@ pub(crate) mod hack {
190202
alloc: A,
191203
) -> Vec<Self, A, COOP_PREFERRED>
192204
where
193-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
205+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(
206+
COOP_PREFERRED,
207+
)]:,
194208
{
195209
let mut v = Vec::with_capacity_in(s.len(), alloc);
196210
// SAFETY:
@@ -472,7 +486,9 @@ impl<T> [T] {
472486
) -> Vec<T, A, COOP_PREFERRED>
473487
where
474488
T: Clone,
475-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
489+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(
490+
COOP_PREFERRED,
491+
)]:,
476492
{
477493
// N.B., see the `hack` module in this file for more details.
478494
hack::to_vec(self, alloc)
@@ -499,7 +515,9 @@ impl<T> [T] {
499515
self: Box<Self, A>,
500516
) -> Vec<T, A, COOP_PREFERRED>
501517
where
502-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
518+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(
519+
COOP_PREFERRED,
520+
)]:,
503521
{
504522
// N.B., see the `hack` module in this file for more details.
505523
hack::into_vec(self)
@@ -816,7 +834,7 @@ impl<T: Clone, V: Borrow<[T]>> Join<&[T]> for [V] {
816834
#[stable(feature = "rust1", since = "1.0.0")]
817835
impl<T, A: Allocator, const COOP_PREFERRED: bool> Borrow<[T]> for Vec<T, A, COOP_PREFERRED>
818836
where
819-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
837+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
820838
{
821839
fn borrow(&self) -> &[T] {
822840
&self[..]
@@ -826,7 +844,7 @@ where
826844
#[stable(feature = "rust1", since = "1.0.0")]
827845
impl<T, A: Allocator, const COOP_PREFERRED: bool> BorrowMut<[T]> for Vec<T, A, COOP_PREFERRED>
828846
where
829-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
847+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
830848
{
831849
fn borrow_mut(&mut self) -> &mut [T] {
832850
&mut self[..]

library/alloc/src/vec/drain.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub struct Drain<
2525
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + 'a = Global,
2626
const COOP_PREFERRED: bool = { alloc::SHORT_TERM_VEC_PREFERS_COOP },
2727
> where
28-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
28+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
2929
{
3030
/// Index of tail to preserve
3131
pub(super) tail_start: usize,
@@ -40,7 +40,7 @@ pub struct Drain<
4040
impl<T: fmt::Debug, A: Allocator, const COOP_PREFERRED: bool> fmt::Debug
4141
for Drain<'_, T, A, COOP_PREFERRED>
4242
where
43-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
43+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
4444
{
4545
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4646
f.debug_tuple("Drain").field(&self.iter.as_slice()).finish()
@@ -49,7 +49,7 @@ where
4949

5050
impl<'a, T, A: Allocator, const COOP_PREFERRED: bool> Drain<'a, T, A, COOP_PREFERRED>
5151
where
52-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
52+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
5353
{
5454
/// Returns the remaining items of this iterator as a slice.
5555
///
@@ -151,7 +151,7 @@ where
151151
#[stable(feature = "vec_drain_as_slice", since = "1.46.0")]
152152
impl<'a, T, A: Allocator, const COOP_PREFERRED: bool> AsRef<[T]> for Drain<'a, T, A, COOP_PREFERRED>
153153
where
154-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
154+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
155155
{
156156
fn as_ref(&self) -> &[T] {
157157
self.as_slice()
@@ -162,21 +162,21 @@ where
162162
unsafe impl<T: Sync, A: Sync + Allocator, const COOP_PREFERRED: bool> Sync
163163
for Drain<'_, T, A, COOP_PREFERRED>
164164
where
165-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
165+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
166166
{
167167
}
168168
#[stable(feature = "drain", since = "1.6.0")]
169169
unsafe impl<T: Send, A: Send + Allocator, const COOP_PREFERRED: bool> Send
170170
for Drain<'_, T, A, COOP_PREFERRED>
171171
where
172-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
172+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
173173
{
174174
}
175175

176176
#[stable(feature = "drain", since = "1.6.0")]
177177
impl<T, A: Allocator, const COOP_PREFERRED: bool> Iterator for Drain<'_, T, A, COOP_PREFERRED>
178178
where
179-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
179+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
180180
{
181181
type Item = T;
182182

@@ -194,7 +194,7 @@ where
194194
impl<T, A: Allocator, const COOP_PREFERRED: bool> DoubleEndedIterator
195195
for Drain<'_, T, A, COOP_PREFERRED>
196196
where
197-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
197+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
198198
{
199199
#[inline]
200200
fn next_back(&mut self) -> Option<T> {
@@ -205,20 +205,20 @@ where
205205
#[stable(feature = "drain", since = "1.6.0")]
206206
impl<T, A: Allocator, const COOP_PREFERRED: bool> Drop for Drain<'_, T, A, COOP_PREFERRED>
207207
where
208-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
208+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
209209
{
210210
fn drop(&mut self) {
211211
/// Moves back the un-`Drain`ed elements to restore the original `Vec`.
212212
struct DropGuard<'r, 'a, T, A: Allocator, const COOP_PREFERRED: bool>(
213213
&'r mut Drain<'a, T, A, COOP_PREFERRED>,
214214
)
215215
where
216-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:;
216+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:;
217217

218218
impl<'r, 'a, T, A: Allocator, const COOP_PREFERRED: bool> Drop
219219
for DropGuard<'r, 'a, T, A, COOP_PREFERRED>
220220
where
221-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
221+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
222222
{
223223
fn drop(&mut self) {
224224
if self.0.tail_len > 0 {
@@ -286,7 +286,7 @@ where
286286
impl<T, A: Allocator, const COOP_PREFERRED: bool> ExactSizeIterator
287287
for Drain<'_, T, A, COOP_PREFERRED>
288288
where
289-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
289+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
290290
{
291291
fn is_empty(&self) -> bool {
292292
self.iter.is_empty()
@@ -297,12 +297,12 @@ where
297297
unsafe impl<T, A: Allocator, const COOP_PREFERRED: bool> TrustedLen
298298
for Drain<'_, T, A, COOP_PREFERRED>
299299
where
300-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
300+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
301301
{
302302
}
303303

304304
#[stable(feature = "fused", since = "1.26.0")]
305305
impl<T, A: Allocator, const COOP_PREFERRED: bool> FusedIterator for Drain<'_, T, A, COOP_PREFERRED> where
306-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:
306+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:
307307
{
308308
}

library/alloc/src/vec/drain_filter.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub struct DrainFilter<
2727
const COOP_PREFERRED: bool = true,
2828
> where
2929
F: FnMut(&mut T) -> bool,
30-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
30+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
3131
{
3232
pub(super) vec: &'a mut Vec<T, A, COOP_PREFERRED>,
3333
/// The index of the item that will be inspected by the next call to `next`.
@@ -49,7 +49,7 @@ pub struct DrainFilter<
4949
impl<T, F, A: Allocator, const COOP_PREFERRED: bool> DrainFilter<'_, T, F, A, COOP_PREFERRED>
5050
where
5151
F: FnMut(&mut T) -> bool,
52-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
52+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
5353
{
5454
/// Returns a reference to the underlying allocator.
5555
#[unstable(feature = "allocator_api", issue = "32838")]
@@ -119,7 +119,7 @@ impl<T, F, A: Allocator, const COOP_PREFERRED: bool> Iterator
119119
for DrainFilter<'_, T, F, A, COOP_PREFERRED>
120120
where
121121
F: FnMut(&mut T) -> bool,
122-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
122+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
123123
{
124124
type Item = T;
125125

@@ -159,13 +159,13 @@ impl<T, F, A: Allocator, const COOP_PREFERRED: bool> Drop
159159
for DrainFilter<'_, T, F, A, COOP_PREFERRED>
160160
where
161161
F: FnMut(&mut T) -> bool,
162-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
162+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
163163
{
164164
fn drop(&mut self) {
165165
struct BackshiftOnDrop<'a, 'b, T, F, A: Allocator, const COOP_PREFERRED: bool>
166166
where
167167
F: FnMut(&mut T) -> bool,
168-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
168+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
169169
{
170170
drain: &'b mut DrainFilter<'a, T, F, A, COOP_PREFERRED>,
171171
}
@@ -174,7 +174,7 @@ where
174174
for BackshiftOnDrop<'a, 'b, T, F, A, COOP_PREFERRED>
175175
where
176176
F: FnMut(&mut T) -> bool,
177-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
177+
[(); alloc::co_alloc_metadata_num_slots_with_preference_specific::<A>(COOP_PREFERRED)]:,
178178
{
179179
fn drop(&mut self) {
180180
unsafe {

0 commit comments

Comments
 (0)