Skip to content

Commit 4a996e6

Browse files
CoAlloc: renamed macro DEFAULT_COOP_PREF -> CO_ALLOC_PREF_DEFAULT
1 parent 37c55a3 commit 4a996e6

File tree

7 files changed

+20
-20
lines changed

7 files changed

+20
-20
lines changed

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

Lines changed: 2 additions & 2 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_PREF;
158+
use crate::CO_ALLOC_PREF_DEFAULT;
159159

160160
use super::SpecExtend;
161161

@@ -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_PREF!() }> {
1667+
impl<T> From<BinaryHeap<T>> for Vec<T, Global, { CO_ALLOC_PREF_DEFAULT!() }> {
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/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
#![feature(global_co_alloc)]
99
#![stable(feature = "rust1", since = "1.0.0")]
10-
use crate::DEFAULT_COOP_PREF;
10+
use crate::CO_ALLOC_PREF_DEFAULT;
1111
use core::alloc;
1212
use core::cmp::{self, Ordering};
1313
use core::fmt;
@@ -97,7 +97,7 @@ mod tests;
9797
pub struct VecDeque<
9898
T,
9999
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
100-
const COOP_PREF: bool = { DEFAULT_COOP_PREF!() },
100+
const COOP_PREF: bool = { CO_ALLOC_PREF_DEFAULT!() },
101101
> where
102102
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
103103
{

library/alloc/src/ffi/c_str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::rc::Rc;
88
use crate::slice::hack::into_vec;
99
use crate::string::String;
1010
use crate::vec::Vec;
11-
use crate::DEFAULT_COOP_PREF;
11+
use crate::CO_ALLOC_PREF_DEFAULT;
1212
use core::borrow::Borrow;
1313
use core::ffi::{c_char, CStr};
1414
use core::fmt;
@@ -726,7 +726,7 @@ impl fmt::Debug for CString {
726726

727727
#[stable(feature = "cstring_into", since = "1.7.0")]
728728
#[allow(unused_braces)]
729-
impl From<CString> for Vec<u8, Global, { DEFAULT_COOP_PREF!() }> {
729+
impl From<CString> for Vec<u8, Global, { CO_ALLOC_PREF_DEFAULT!() }> {
730730
/// Converts a [`CString`] into a <code>[Vec]<[u8]></code>.
731731
///
732732
/// The conversion consumes the [`CString`], and removes the terminating NUL byte.

library/alloc/src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ macro_rules! __rust_force_expr {
134134
// fixed. Then move the const to a submodule, for example alloc::co_alloc.
135135
#[unstable(feature = "global_co_alloc_default", issue = "none")]
136136
#[macro_export]
137-
macro_rules! DEFAULT_COOP_PREF {
137+
macro_rules! CO_ALLOC_PREF_DEFAULT {
138138
() => {
139139
true
140140
};

library/alloc/src/raw_vec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::alloc::{Allocator, Global, Layout};
1616
use crate::boxed::Box;
1717
use crate::collections::TryReserveError;
1818
use crate::collections::TryReserveErrorKind::*;
19-
use crate::DEFAULT_COOP_PREF;
19+
use crate::CO_ALLOC_PREF_DEFAULT;
2020

2121
#[cfg(test)]
2222
mod tests;
@@ -52,8 +52,8 @@ enum AllocInit {
5252
/// `usize::MAX`. This means that you need to be careful when round-tripping this type with a
5353
/// `Box<[T]>`, since `capacity()` won't yield the length.
5454
#[allow(missing_debug_implementations)]
55-
#[allow(unused_braces)]
56-
pub(crate) struct RawVec<T, A: Allocator = Global, const COOP_PREF: bool = { DEFAULT_COOP_PREF!() }>
55+
#[allow(unused_braces)] //@FIXME remove #[allow(unused_braces)] once that false positive warning fix is included on stable
56+
pub(crate) struct RawVec<T, A: Allocator = Global, const COOP_PREF: bool = { CO_ALLOC_PREF_DEFAULT!() }>
5757
where
5858
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
5959
{

library/alloc/src/vec/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ pub struct Vec<
403403
T,
404404
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
405405
//@FIXME: #[unstable(feature ="global_co_alloc_vec", issue="none")]
406-
const COOP_PREF: bool = { DEFAULT_COOP_PREF!() },
406+
const COOP_PREF: bool = { CO_ALLOC_PREF_DEFAULT!() },
407407
> where
408408
[(); core::alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREF)]:,
409409
{
@@ -425,7 +425,7 @@ pub type PlVec<T, A = Global> = Vec<T, A, false>;
425425
/// author considered using `CoVec` or `PlVec`, but left it to default instead.
426426
#[unstable(feature = "global_co_alloc_defvec", issue = "none")]
427427
#[allow(unused_braces)]
428-
pub type DefVec<T, A = Global> = Vec<T, A, { DEFAULT_COOP_PREF!() }>;
428+
pub type DefVec<T, A = Global> = Vec<T, A, { CO_ALLOC_PREF_DEFAULT!() }>;
429429

430430
/// "Weighted cooperative" Vec. Weight means how much it wants to cooperate (with the allocator). 0
431431
/// = always pack; u8::MAX = always cooperate (if `Global` supports it).
@@ -454,7 +454,7 @@ impl<T> Vec<T> {
454454
#[must_use]
455455
pub const fn new() -> Self {
456456
#[allow(unused_braces)]
457-
Vec::<T, Global, { DEFAULT_COOP_PREF!() }>::new_co()
457+
Vec::<T, Global, { CO_ALLOC_PREF_DEFAULT!() }>::new_co()
458458
//Self::new_co()
459459
}
460460

@@ -3317,7 +3317,7 @@ where
33173317
#[cfg(not(no_global_oom_handling))]
33183318
#[stable(feature = "rust1", since = "1.0.0")]
33193319
#[allow(unused_braces)]
3320-
impl<T: Clone> From<&[T]> for Vec<T, Global, { DEFAULT_COOP_PREF!() }> {
3320+
impl<T: Clone> From<&[T]> for Vec<T, Global, { CO_ALLOC_PREF_DEFAULT!() }> {
33213321
/// Allocate a `Vec<T>` and fill it by cloning `s`'s items.
33223322
///
33233323
/// # Examples
@@ -3338,7 +3338,7 @@ impl<T: Clone> From<&[T]> for Vec<T, Global, { DEFAULT_COOP_PREF!() }> {
33383338
#[cfg(not(no_global_oom_handling))]
33393339
#[stable(feature = "vec_from_mut", since = "1.19.0")]
33403340
#[allow(unused_braces)]
3341-
impl<T: Clone> From<&mut [T]> for Vec<T, Global, { DEFAULT_COOP_PREF!() }> {
3341+
impl<T: Clone> From<&mut [T]> for Vec<T, Global, { CO_ALLOC_PREF_DEFAULT!() }> {
33423342
/// Allocate a `Vec<T>` and fill it by cloning `s`'s items.
33433343
///
33443344
/// # Examples
@@ -3359,7 +3359,7 @@ impl<T: Clone> From<&mut [T]> for Vec<T, Global, { DEFAULT_COOP_PREF!() }> {
33593359
#[cfg(not(no_global_oom_handling))]
33603360
#[stable(feature = "vec_from_array", since = "1.44.0")]
33613361
#[allow(unused_braces)]
3362-
impl<T, const N: usize> From<[T; N]> for Vec<T, Global, { DEFAULT_COOP_PREF!() }> {
3362+
impl<T, const N: usize> From<[T; N]> for Vec<T, Global, { CO_ALLOC_PREF_DEFAULT!() }> {
33633363
/// Allocate a `Vec<T>` and move `s`'s items into it.
33643364
///
33653365
/// # Examples
@@ -3383,7 +3383,7 @@ impl<T, const N: usize> From<[T; N]> for Vec<T, Global, { DEFAULT_COOP_PREF!() }
33833383

33843384
#[stable(feature = "vec_from_cow_slice", since = "1.14.0")]
33853385
#[allow(unused_braces)]
3386-
impl<'a, T> From<Cow<'a, [T]>> for Vec<T, Global, { DEFAULT_COOP_PREF!() }>
3386+
impl<'a, T> From<Cow<'a, [T]>> for Vec<T, Global, { CO_ALLOC_PREF_DEFAULT!() }>
33873387
where
33883388
[T]: ToOwned<Owned = Vec<T>>,
33893389
{
@@ -3461,7 +3461,7 @@ where
34613461
#[cfg(not(no_global_oom_handling))]
34623462
#[stable(feature = "rust1", since = "1.0.0")]
34633463
#[allow(unused_braces)]
3464-
impl From<&str> for Vec<u8, Global, { DEFAULT_COOP_PREF!() }> {
3464+
impl From<&str> for Vec<u8, Global, { CO_ALLOC_PREF_DEFAULT!() }> {
34653465
/// Allocate a `Vec<u8>` and fill it with a UTF-8 string.
34663466
///
34673467
/// # Examples

library/alloc/src/vec/spec_from_iter_nested.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use core::ptr;
55

66
use crate::alloc::Global;
77
use crate::raw_vec::RawVec;
8-
use crate::DEFAULT_COOP_PREF;
8+
use crate::CO_ALLOC_PREF_DEFAULT;
99

1010
use super::{SpecExtend, Vec};
1111

@@ -51,7 +51,7 @@ where
5151
}
5252

5353
#[allow(unused_braces)]
54-
impl<T, I> SpecFromIterNested<T, I> for Vec<T, Global, { DEFAULT_COOP_PREF!() }>
54+
impl<T, I> SpecFromIterNested<T, I> for Vec<T, Global, { CO_ALLOC_PREF_DEFAULT!() }>
5555
where
5656
I: TrustedLen<Item = T>,
5757
{

0 commit comments

Comments
 (0)