Skip to content

Commit 4aea4f9

Browse files
CoAlloc: Using config + transformation macros in ::alloc. ICE!
1 parent 268e6e3 commit 4aea4f9

25 files changed

+317
-159
lines changed

library/alloc/src/boxed.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ impl<T> Box<[T]> {
748748
}
749749
}
750750

751+
#[allow(unused_braces)]
751752
impl<T, A: Allocator> Box<[T], A>
752753
where
753754
[(); {crate::meta_num_slots!(A, crate::CO_ALLOC_PREF_META_NO!())}]:,
@@ -1680,6 +1681,7 @@ impl<T, const N: usize> TryFrom<Box<[T]>> for Box<[T; N]> {
16801681

16811682
#[cfg(not(no_global_oom_handling))]
16821683
#[stable(feature = "boxed_array_try_from_vec", since = "1.66.0")]
1684+
#[allow(unused_braces)]
16831685
impl<T, const N: usize, const CO_ALLOC_PREF: CoAllocPref> TryFrom<Vec<T, Global, CO_ALLOC_PREF>> for Box<[T; N]>
16841686
where
16851687
[(); {meta_num_slots_global!(CO_ALLOC_PREF)}]:,
@@ -2041,6 +2043,7 @@ impl<I> FromIterator<I> for Box<[I]> {
20412043

20422044
#[cfg(not(no_global_oom_handling))]
20432045
#[stable(feature = "box_slice_clone", since = "1.3.0")]
2046+
#[allow(unused_braces)]
20442047
impl<T: Clone, A: Allocator + Clone> Clone for Box<[T], A>
20452048
where
20462049
[(); {crate::meta_num_slots!(A, crate::CO_ALLOC_PREF_META_NO!())}]:,

library/alloc/src/collections/binary_heap/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@ impl<T> BinaryHeap<T> {
12461246
#[inline]
12471247
#[stable(feature = "drain", since = "1.6.0")]
12481248
#[allow(unused_braces)]
1249-
pub fn drain(&mut self) -> Drain<'_, T, { SHORT_TERM_VEC_PREFERS_COOP!() }> {
1249+
pub fn drain(&mut self) -> Drain<'_, T, { SHORT_TERM_VEC_CO_ALLOC_PREF!() }> {
12501250
Drain { iter: self.data.drain(..) }
12511251
}
12521252

@@ -1526,6 +1526,7 @@ unsafe impl<T: Ord> TrustedLen for IntoIterSorted<T> {}
15261526
/// [`drain`]: BinaryHeap::drain
15271527
#[stable(feature = "drain", since = "1.6.0")]
15281528
#[derive(Debug)]
1529+
#[allow(unused_braces)]
15291530
pub struct Drain<'a, T: 'a, const CO_ALLOC_PREF: CoAllocPref>
15301531
where
15311532
[(); {meta_num_slots_global!(CO_ALLOC_PREF)}]:,
@@ -1534,6 +1535,7 @@ where
15341535
}
15351536

15361537
#[stable(feature = "drain", since = "1.6.0")]
1538+
#[allow(unused_braces)]
15371539
impl<T, const CO_ALLOC_PREF: CoAllocPref> Iterator for Drain<'_, T, CO_ALLOC_PREF>
15381540
where
15391541
[(); {meta_num_slots_global!(CO_ALLOC_PREF)}]:,
@@ -1552,6 +1554,7 @@ where
15521554
}
15531555

15541556
#[stable(feature = "drain", since = "1.6.0")]
1557+
#[allow(unused_braces)]
15551558
impl<T, const CO_ALLOC_PREF: CoAllocPref> DoubleEndedIterator for Drain<'_, T, CO_ALLOC_PREF>
15561559
where
15571560
[(); {meta_num_slots_global!(CO_ALLOC_PREF)}]:,
@@ -1563,6 +1566,7 @@ where
15631566
}
15641567

15651568
#[stable(feature = "drain", since = "1.6.0")]
1569+
#[allow(unused_braces)]
15661570
impl<T, const CO_ALLOC_PREF: CoAllocPref> ExactSizeIterator for Drain<'_, T, CO_ALLOC_PREF>
15671571
where
15681572
[(); {meta_num_slots_global!(CO_ALLOC_PREF)}]:,
@@ -1573,6 +1577,7 @@ where
15731577
}
15741578

15751579
#[stable(feature = "fused", since = "1.26.0")]
1580+
#[allow(unused_braces)]
15761581
impl<T, const CO_ALLOC_PREF: CoAllocPref> FusedIterator for Drain<'_, T, CO_ALLOC_PREF> where
15771582
[(); {meta_num_slots_global!(CO_ALLOC_PREF)}]:
15781583
{

library/alloc/src/collections/vec_deque/drain.rs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::co_alloc::CoAllocPref;
33
use core::marker::PhantomData;
44
use core::mem::{self, SizedTypeProperties};
55
use core::ptr::NonNull;
6-
use core::{alloc, fmt, ptr};
6+
use core::{fmt, ptr};
77

88
use crate::alloc::{Allocator, Global};
99

@@ -21,9 +21,9 @@ pub struct Drain<
2121
'a,
2222
T: 'a,
2323
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
24-
const CO_ALLOC_PREF: CoAllocPref = { SHORT_TERM_VEC_PREFERS_COOP!() },
24+
const CO_ALLOC_PREF: CoAllocPref = { SHORT_TERM_VEC_CO_ALLOC_PREF!() },
2525
> where
26-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(CO_ALLOC_PREF)]:,
26+
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:,
2727
{
2828
// We can't just use a &mut VecDeque<T, A>, as that would make Drain invariant over T
2929
// and we want it to be covariant instead
@@ -39,9 +39,10 @@ pub struct Drain<
3939
_marker: PhantomData<&'a T>,
4040
}
4141

42+
#[allow(unused_braces)]
4243
impl<'a, T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> Drain<'a, T, A, CO_ALLOC_PREF>
4344
where
44-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(CO_ALLOC_PREF)]:,
45+
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:,
4546
{
4647
pub(super) unsafe fn new(
4748
deque: &'a mut VecDeque<T, A, CO_ALLOC_PREF>,
@@ -96,9 +97,10 @@ where
9697
}
9798

9899
#[stable(feature = "collection_debug", since = "1.17.0")]
100+
#[allow(unused_braces)]
99101
impl<T: fmt::Debug, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> fmt::Debug for Drain<'_, T, A, CO_ALLOC_PREF>
100102
where
101-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(CO_ALLOC_PREF)]:,
103+
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:,
102104
{
103105
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
104106
f.debug_tuple("Drain")
@@ -111,31 +113,34 @@ where
111113
}
112114

113115
#[stable(feature = "drain", since = "1.6.0")]
116+
#[allow(unused_braces)]
114117
unsafe impl<T: Sync, A: Allocator + Sync, const CO_ALLOC_PREF: CoAllocPref> Sync for Drain<'_, T, A, CO_ALLOC_PREF> where
115-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(CO_ALLOC_PREF)]:
118+
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:
116119
{
117120
}
118121
#[stable(feature = "drain", since = "1.6.0")]
122+
#[allow(unused_braces)]
119123
unsafe impl<T: Send, A: Allocator + Send, const CO_ALLOC_PREF: CoAllocPref> Send for Drain<'_, T, A, CO_ALLOC_PREF> where
120-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(CO_ALLOC_PREF)]:
124+
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:
121125
{
122126
}
123127

124128
#[stable(feature = "drain", since = "1.6.0")]
129+
#[allow(unused_braces)]
125130
impl<T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> Drop for Drain<'_, T, A, CO_ALLOC_PREF>
126131
where
127-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(CO_ALLOC_PREF)]:,
132+
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:,
128133
{
129134
fn drop(&mut self) {
130135
struct DropGuard<'r, 'a, T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref>(
131136
&'r mut Drain<'a, T, A, CO_ALLOC_PREF>,
132137
)
133138
where
134-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(CO_ALLOC_PREF)]:;
139+
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:;
135140

136141
impl<'r, 'a, T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> Drop for DropGuard<'r, 'a, T, A, CO_ALLOC_PREF>
137142
where
138-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(CO_ALLOC_PREF)]:,
143+
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:,
139144
{
140145
fn drop(&mut self) {
141146
if self.0.remaining != 0 {
@@ -217,9 +222,10 @@ where
217222
}
218223

219224
#[stable(feature = "drain", since = "1.6.0")]
225+
#[allow(unused_braces)]
220226
impl<T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> Iterator for Drain<'_, T, A, CO_ALLOC_PREF>
221227
where
222-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(CO_ALLOC_PREF)]:,
228+
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:,
223229
{
224230
type Item = T;
225231

@@ -242,9 +248,10 @@ where
242248
}
243249

244250
#[stable(feature = "drain", since = "1.6.0")]
251+
#[allow(unused_braces)]
245252
impl<T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> DoubleEndedIterator for Drain<'_, T, A, CO_ALLOC_PREF>
246253
where
247-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(CO_ALLOC_PREF)]:,
254+
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:,
248255
{
249256
#[inline]
250257
fn next_back(&mut self) -> Option<T> {
@@ -258,13 +265,15 @@ where
258265
}
259266

260267
#[stable(feature = "drain", since = "1.6.0")]
268+
#[allow(unused_braces)]
261269
impl<T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> ExactSizeIterator for Drain<'_, T, A, CO_ALLOC_PREF> where
262-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(CO_ALLOC_PREF)]:
270+
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:
263271
{
264272
}
265273

266274
#[stable(feature = "fused", since = "1.26.0")]
275+
#[allow(unused_braces)]
267276
impl<T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> FusedIterator for Drain<'_, T, A, CO_ALLOC_PREF> where
268-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(CO_ALLOC_PREF)]:
277+
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:
269278
{
270279
}

library/alloc/src/collections/vec_deque/into_iter.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,18 @@ use super::VecDeque;
1414
/// [`IntoIterator`]: core::iter::IntoIterator
1515
#[derive(Clone)]
1616
#[stable(feature = "rust1", since = "1.0.0")]
17+
#[allow(unused_braces)]
1718
pub struct IntoIter<
1819
T,
1920
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
20-
const CO_ALLOC_PREF: CoAllocPref = true,
21+
const CO_ALLOC_PREF: CoAllocPref = {CO_ALLOC_PREF_DEFAULT!()},
2122
> where
22-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(CO_ALLOC_PREF)]:,
23+
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:,
2324
{
2425
inner: VecDeque<T, A, CO_ALLOC_PREF>,
2526
}
2627

28+
#[allow(unused_braces)]
2729
impl<T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> IntoIter<T, A, CO_ALLOC_PREF>
2830
where
2931
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:,
@@ -38,6 +40,7 @@ where
3840
}
3941

4042
#[stable(feature = "collection_debug", since = "1.17.0")]
43+
#[allow(unused_braces)]
4144
impl<T: fmt::Debug, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> fmt::Debug for IntoIter<T, A, CO_ALLOC_PREF>
4245
where
4346
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:,
@@ -48,6 +51,7 @@ where
4851
}
4952

5053
#[stable(feature = "rust1", since = "1.0.0")]
54+
#[allow(unused_braces)]
5155
impl<T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> Iterator for IntoIter<T, A, CO_ALLOC_PREF>
5256
where
5357
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:,
@@ -187,6 +191,7 @@ where
187191
}
188192

189193
#[stable(feature = "rust1", since = "1.0.0")]
194+
#[allow(unused_braces)]
190195
impl<T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> DoubleEndedIterator for IntoIter<T, A, CO_ALLOC_PREF>
191196
where
192197
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:,
@@ -260,6 +265,7 @@ where
260265
}
261266

262267
#[stable(feature = "rust1", since = "1.0.0")]
268+
#[allow(unused_braces)]
263269
impl<T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> ExactSizeIterator for IntoIter<T, A, CO_ALLOC_PREF>
264270
where
265271
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:,
@@ -271,12 +277,14 @@ where
271277
}
272278

273279
#[stable(feature = "fused", since = "1.26.0")]
280+
#[allow(unused_braces)]
274281
impl<T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> FusedIterator for IntoIter<T, A, CO_ALLOC_PREF> where
275282
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:
276283
{
277284
}
278285

279286
#[unstable(feature = "trusted_len", issue = "37572")]
287+
#[allow(unused_braces)]
280288
unsafe impl<T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> TrustedLen for IntoIter<T, A, CO_ALLOC_PREF> where
281289
[(); {crate::meta_num_slots!(A, CO_ALLOC_PREF)}]:
282290
{

0 commit comments

Comments
 (0)