Skip to content

Commit 327596a

Browse files
CoAlloc: Using the new macros (not everywhere yet).
1 parent ddb3a41 commit 327596a

29 files changed

+588
-599
lines changed

library/alloc/src/boxed.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,12 +1679,12 @@ impl<T, const N: usize> TryFrom<Box<[T]>> for Box<[T; N]> {
16791679

16801680
#[cfg(not(no_global_oom_handling))]
16811681
#[stable(feature = "boxed_array_try_from_vec", since = "1.66.0")]
1682-
impl<T, const N: usize, const COOP_PREFERRED: bool> TryFrom<Vec<T, Global, COOP_PREFERRED>>
1682+
impl<T, const N: usize, const COOP_PREF: bool> TryFrom<Vec<T, Global, COOP_PREF>>
16831683
for Box<[T; N]>
16841684
where
1685-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREFERRED)]:,
1685+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREF)]:,
16861686
{
1687-
type Error = Vec<T, Global, COOP_PREFERRED>;
1687+
type Error = Vec<T, Global, COOP_PREF>;
16881688

16891689
/// Attempts to convert a `Vec<T>` into a `Box<[T; N]>`.
16901690
///
@@ -1704,7 +1704,7 @@ where
17041704
/// let state: Box<[f32; 100]> = vec![1.0; 100].try_into().unwrap();
17051705
/// assert_eq!(state.len(), 100);
17061706
/// ```
1707-
fn try_from(vec: Vec<T, Global, COOP_PREFERRED>) -> Result<Self, Self::Error> {
1707+
fn try_from(vec: Vec<T, Global, COOP_PREF>) -> Result<Self, Self::Error> {
17081708
if vec.len() == N {
17091709
let boxed_slice = vec.into_boxed_slice();
17101710
Ok(unsafe { boxed_slice_as_array_unchecked(boxed_slice) })

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ use crate::alloc::Global;
155155
use crate::collections::TryReserveError;
156156
use crate::slice;
157157
use crate::vec::{self, AsVecIntoIter, Vec};
158-
use crate::DEFAULT_COOP_PREFERRED;
158+
use crate::DEFAULT_COOP_PREF;
159159

160160
use super::SpecExtend;
161161

@@ -1525,17 +1525,17 @@ unsafe impl<T: Ord> TrustedLen for IntoIterSorted<T> {}
15251525
/// [`drain`]: BinaryHeap::drain
15261526
#[stable(feature = "drain", since = "1.6.0")]
15271527
#[derive(Debug)]
1528-
pub struct Drain<'a, T: 'a, const COOP_PREFERRED: bool>
1528+
pub struct Drain<'a, T: 'a, const COOP_PREF: bool>
15291529
where
1530-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREFERRED)]:,
1530+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREF)]:,
15311531
{
1532-
iter: vec::Drain<'a, T, Global, COOP_PREFERRED>,
1532+
iter: vec::Drain<'a, T, Global, COOP_PREF>,
15331533
}
15341534

15351535
#[stable(feature = "drain", since = "1.6.0")]
1536-
impl<T, const COOP_PREFERRED: bool> Iterator for Drain<'_, T, COOP_PREFERRED>
1536+
impl<T, const COOP_PREF: bool> Iterator for Drain<'_, T, COOP_PREF>
15371537
where
1538-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREFERRED)]:,
1538+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREF)]:,
15391539
{
15401540
type Item = T;
15411541

@@ -1551,9 +1551,9 @@ where
15511551
}
15521552

15531553
#[stable(feature = "drain", since = "1.6.0")]
1554-
impl<T, const COOP_PREFERRED: bool> DoubleEndedIterator for Drain<'_, T, COOP_PREFERRED>
1554+
impl<T, const COOP_PREF: bool> DoubleEndedIterator for Drain<'_, T, COOP_PREF>
15551555
where
1556-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREFERRED)]:,
1556+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREF)]:,
15571557
{
15581558
#[inline]
15591559
fn next_back(&mut self) -> Option<T> {
@@ -1562,18 +1562,18 @@ where
15621562
}
15631563

15641564
#[stable(feature = "drain", since = "1.6.0")]
1565-
impl<T, const COOP_PREFERRED: bool> ExactSizeIterator for Drain<'_, T, COOP_PREFERRED>
1565+
impl<T, const COOP_PREF: bool> ExactSizeIterator for Drain<'_, T, COOP_PREF>
15661566
where
1567-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREFERRED)]:,
1567+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREF)]:,
15681568
{
15691569
fn is_empty(&self) -> bool {
15701570
self.iter.is_empty()
15711571
}
15721572
}
15731573

15741574
#[stable(feature = "fused", since = "1.26.0")]
1575-
impl<T, const COOP_PREFERRED: bool> FusedIterator for Drain<'_, T, COOP_PREFERRED> where
1576-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREFERRED)]:
1575+
impl<T, const COOP_PREF: bool> FusedIterator for Drain<'_, T, COOP_PREF> where
1576+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<Global>(COOP_PREF)]:
15771577
{
15781578
}
15791579

@@ -1664,7 +1664,7 @@ impl<T: Ord, const N: usize> From<[T; N]> for BinaryHeap<T> {
16641664

16651665
#[stable(feature = "binary_heap_extras_15", since = "1.5.0")]
16661666
#[allow(unused_braces)]
1667-
impl<T> From<BinaryHeap<T>> for Vec<T, Global, { DEFAULT_COOP_PREFERRED!() }> {
1667+
impl<T> From<BinaryHeap<T>> for Vec<T, Global, { DEFAULT_COOP_PREF!() }> {
16681668
/// Converts a `BinaryHeap<T>` into a `Vec<T>`.
16691669
///
16701670
/// This conversion requires no data movement or allocation, and has

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

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ pub struct Drain<
2020
'a,
2121
T: 'a,
2222
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
23-
const COOP_PREFERRED: bool = { SHORT_TERM_VEC_PREFERS_COOP!() },
23+
const COOP_PREF: bool = { SHORT_TERM_VEC_PREFERS_COOP!() },
2424
> where
25-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
25+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
2626
{
2727
// We can't just use a &mut VecDeque<T, A>, as that would make Drain invariant over T
2828
// and we want it to be covariant instead
29-
deque: NonNull<VecDeque<T, A, COOP_PREFERRED>>,
29+
deque: NonNull<VecDeque<T, A, COOP_PREF>>,
3030
// drain_start is stored in deque.len
3131
drain_len: usize,
3232
// index into the logical array, not the physical one (always lies in [0..deque.len))
@@ -38,12 +38,12 @@ pub struct Drain<
3838
_marker: PhantomData<&'a T>,
3939
}
4040

41-
impl<'a, T, A: Allocator, const COOP_PREFERRED: bool> Drain<'a, T, A, COOP_PREFERRED>
41+
impl<'a, T, A: Allocator, const COOP_PREF: bool> Drain<'a, T, A, COOP_PREF>
4242
where
43-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
43+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
4444
{
4545
pub(super) unsafe fn new(
46-
deque: &'a mut VecDeque<T, A, COOP_PREFERRED>,
46+
deque: &'a mut VecDeque<T, A, COOP_PREF>,
4747
drain_start: usize,
4848
drain_len: usize,
4949
) -> Self {
@@ -95,10 +95,10 @@ where
9595
}
9696

9797
#[stable(feature = "collection_debug", since = "1.17.0")]
98-
impl<T: fmt::Debug, A: Allocator, const COOP_PREFERRED: bool> fmt::Debug
99-
for Drain<'_, T, A, COOP_PREFERRED>
98+
impl<T: fmt::Debug, A: Allocator, const COOP_PREF: bool> fmt::Debug
99+
for Drain<'_, T, A, COOP_PREF>
100100
where
101-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
101+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
102102
{
103103
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
104104
f.debug_tuple("Drain")
@@ -111,36 +111,36 @@ where
111111
}
112112

113113
#[stable(feature = "drain", since = "1.6.0")]
114-
unsafe impl<T: Sync, A: Allocator + Sync, const COOP_PREFERRED: bool> Sync
115-
for Drain<'_, T, A, COOP_PREFERRED>
114+
unsafe impl<T: Sync, A: Allocator + Sync, const COOP_PREF: bool> Sync
115+
for Drain<'_, T, A, COOP_PREF>
116116
where
117-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
117+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
118118
{
119119
}
120120
#[stable(feature = "drain", since = "1.6.0")]
121-
unsafe impl<T: Send, A: Allocator + Send, const COOP_PREFERRED: bool> Send
122-
for Drain<'_, T, A, COOP_PREFERRED>
121+
unsafe impl<T: Send, A: Allocator + Send, const COOP_PREF: bool> Send
122+
for Drain<'_, T, A, COOP_PREF>
123123
where
124-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
124+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
125125
{
126126
}
127127

128128
#[stable(feature = "drain", since = "1.6.0")]
129-
impl<T, A: Allocator, const COOP_PREFERRED: bool> Drop for Drain<'_, T, A, COOP_PREFERRED>
129+
impl<T, A: Allocator, const COOP_PREF: bool> Drop for Drain<'_, T, A, COOP_PREF>
130130
where
131-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
131+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
132132
{
133133
fn drop(&mut self) {
134-
struct DropGuard<'r, 'a, T, A: Allocator, const COOP_PREFERRED: bool>(
135-
&'r mut Drain<'a, T, A, COOP_PREFERRED>,
134+
struct DropGuard<'r, 'a, T, A: Allocator, const COOP_PREF: bool>(
135+
&'r mut Drain<'a, T, A, COOP_PREF>,
136136
)
137137
where
138-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:;
138+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:;
139139

140-
impl<'r, 'a, T, A: Allocator, const COOP_PREFERRED: bool> Drop
141-
for DropGuard<'r, 'a, T, A, COOP_PREFERRED>
140+
impl<'r, 'a, T, A: Allocator, const COOP_PREF: bool> Drop
141+
for DropGuard<'r, 'a, T, A, COOP_PREF>
142142
where
143-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
143+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
144144
{
145145
fn drop(&mut self) {
146146
if self.0.remaining != 0 {
@@ -222,9 +222,9 @@ where
222222
}
223223

224224
#[stable(feature = "drain", since = "1.6.0")]
225-
impl<T, A: Allocator, const COOP_PREFERRED: bool> Iterator for Drain<'_, T, A, COOP_PREFERRED>
225+
impl<T, A: Allocator, const COOP_PREF: bool> Iterator for Drain<'_, T, A, COOP_PREF>
226226
where
227-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
227+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
228228
{
229229
type Item = T;
230230

@@ -247,10 +247,10 @@ where
247247
}
248248

249249
#[stable(feature = "drain", since = "1.6.0")]
250-
impl<T, A: Allocator, const COOP_PREFERRED: bool> DoubleEndedIterator
251-
for Drain<'_, T, A, COOP_PREFERRED>
250+
impl<T, A: Allocator, const COOP_PREF: bool> DoubleEndedIterator
251+
for Drain<'_, T, A, COOP_PREF>
252252
where
253-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
253+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
254254
{
255255
#[inline]
256256
fn next_back(&mut self) -> Option<T> {
@@ -264,15 +264,15 @@ where
264264
}
265265

266266
#[stable(feature = "drain", since = "1.6.0")]
267-
impl<T, A: Allocator, const COOP_PREFERRED: bool> ExactSizeIterator
268-
for Drain<'_, T, A, COOP_PREFERRED>
267+
impl<T, A: Allocator, const COOP_PREF: bool> ExactSizeIterator
268+
for Drain<'_, T, A, COOP_PREF>
269269
where
270-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
270+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
271271
{
272272
}
273273

274274
#[stable(feature = "fused", since = "1.26.0")]
275-
impl<T, A: Allocator, const COOP_PREFERRED: bool> FusedIterator for Drain<'_, T, A, COOP_PREFERRED> where
276-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:
275+
impl<T, A: Allocator, const COOP_PREF: bool> FusedIterator for Drain<'_, T, A, COOP_PREF> where
276+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:
277277
{
278278
}

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

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,41 @@ use super::VecDeque;
1717
pub struct IntoIter<
1818
T,
1919
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
20-
const COOP_PREFERRED: bool = true,
20+
const COOP_PREF: bool = true,
2121
> where
22-
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
22+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
2323
{
24-
inner: VecDeque<T, A, COOP_PREFERRED>,
24+
inner: VecDeque<T, A, COOP_PREF>,
2525
}
2626

27-
impl<T, A: Allocator, const COOP_PREFERRED: bool> IntoIter<T, A, COOP_PREFERRED>
27+
impl<T, A: Allocator, const COOP_PREF: bool> IntoIter<T, A, COOP_PREF>
2828
where
29-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
29+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
3030
{
31-
pub(super) fn new(inner: VecDeque<T, A, COOP_PREFERRED>) -> Self {
31+
pub(super) fn new(inner: VecDeque<T, A, COOP_PREF>) -> Self {
3232
IntoIter { inner }
3333
}
3434

35-
pub(super) fn into_vecdeque(self) -> VecDeque<T, A, COOP_PREFERRED> {
35+
pub(super) fn into_vecdeque(self) -> VecDeque<T, A, COOP_PREF> {
3636
self.inner
3737
}
3838
}
3939

4040
#[stable(feature = "collection_debug", since = "1.17.0")]
41-
impl<T: fmt::Debug, A: Allocator, const COOP_PREFERRED: bool> fmt::Debug
42-
for IntoIter<T, A, COOP_PREFERRED>
41+
impl<T: fmt::Debug, A: Allocator, const COOP_PREF: bool> fmt::Debug
42+
for IntoIter<T, A, COOP_PREF>
4343
where
44-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
44+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
4545
{
4646
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4747
f.debug_tuple("IntoIter").field(&self.inner).finish()
4848
}
4949
}
5050

5151
#[stable(feature = "rust1", since = "1.0.0")]
52-
impl<T, A: Allocator, const COOP_PREFERRED: bool> Iterator for IntoIter<T, A, COOP_PREFERRED>
52+
impl<T, A: Allocator, const COOP_PREF: bool> Iterator for IntoIter<T, A, COOP_PREF>
5353
where
54-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
54+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
5555
{
5656
type Item = T;
5757

@@ -188,10 +188,10 @@ where
188188
}
189189

190190
#[stable(feature = "rust1", since = "1.0.0")]
191-
impl<T, A: Allocator, const COOP_PREFERRED: bool> DoubleEndedIterator
192-
for IntoIter<T, A, COOP_PREFERRED>
191+
impl<T, A: Allocator, const COOP_PREF: bool> DoubleEndedIterator
192+
for IntoIter<T, A, COOP_PREF>
193193
where
194-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
194+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
195195
{
196196
#[inline]
197197
fn next_back(&mut self) -> Option<T> {
@@ -262,10 +262,10 @@ where
262262
}
263263

264264
#[stable(feature = "rust1", since = "1.0.0")]
265-
impl<T, A: Allocator, const COOP_PREFERRED: bool> ExactSizeIterator
266-
for IntoIter<T, A, COOP_PREFERRED>
265+
impl<T, A: Allocator, const COOP_PREF: bool> ExactSizeIterator
266+
for IntoIter<T, A, COOP_PREF>
267267
where
268-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
268+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
269269
{
270270
#[inline]
271271
fn is_empty(&self) -> bool {
@@ -274,15 +274,15 @@ where
274274
}
275275

276276
#[stable(feature = "fused", since = "1.26.0")]
277-
impl<T, A: Allocator, const COOP_PREFERRED: bool> FusedIterator for IntoIter<T, A, COOP_PREFERRED> where
278-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:
277+
impl<T, A: Allocator, const COOP_PREF: bool> FusedIterator for IntoIter<T, A, COOP_PREF> where
278+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:
279279
{
280280
}
281281

282282
#[unstable(feature = "trusted_len", issue = "37572")]
283-
unsafe impl<T, A: Allocator, const COOP_PREFERRED: bool> TrustedLen
284-
for IntoIter<T, A, COOP_PREFERRED>
283+
unsafe impl<T, A: Allocator, const COOP_PREF: bool> TrustedLen
284+
for IntoIter<T, A, COOP_PREF>
285285
where
286-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
286+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
287287
{
288288
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
macro_rules! __impl_slice_eq1 {
22
([$($vars:tt)*] $lhs:ty, $rhs:ty, $($constraints:tt)*) => {
33
#[stable(feature = "vec_deque_partial_eq_slice", since = "1.17.0")]
4-
impl<T, U, A: Allocator, const COOP_PREFERRED: bool, $($vars)*> PartialEq<$rhs> for $lhs
4+
impl<T, U, A: Allocator, const COOP_PREF: bool, $($vars)*> PartialEq<$rhs> for $lhs
55
where
66
T: PartialEq<U>,
7-
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
7+
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
88
$($constraints)*
99
{
1010
fn eq(&self, other: &$rhs) -> bool {

0 commit comments

Comments
 (0)