Skip to content

Commit 017b05d

Browse files
Moved co_alloc_metadata_num_slots_with_preference_global from ::core::alloc to ::alloc.
1 parent 4bc88b4 commit 017b05d

File tree

9 files changed

+87
-94
lines changed

9 files changed

+87
-94
lines changed

library/alloc/src/boxed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1686,7 +1686,7 @@ impl<T, const N: usize> TryFrom<Box<[T]>> for Box<[T; N]> {
16861686
impl<T, const N: usize, const COOP_PREFERRED: bool> TryFrom<Vec<T, Global, COOP_PREFERRED>>
16871687
for Box<[T; N]>
16881688
where
1689-
[(); alloc::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
1689+
[(); crate::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
16901690
{
16911691
type Error = Vec<T, Global, COOP_PREFERRED>;
16921692

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,15 +1525,15 @@ unsafe impl<T: Ord> TrustedLen for IntoIterSorted<T> {}
15251525
#[derive(Debug)]
15261526
pub struct Drain<'a, T: 'a, const COOP_PREFERRED: bool>
15271527
where
1528-
[(); alloc::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
1528+
[(); crate::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
15291529
{
15301530
iter: vec::Drain<'a, T, Global, COOP_PREFERRED>,
15311531
}
15321532

15331533
#[stable(feature = "drain", since = "1.6.0")]
15341534
impl<T, const COOP_PREFERRED: bool> Iterator for Drain<'_, T, COOP_PREFERRED>
15351535
where
1536-
[(); alloc::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
1536+
[(); crate::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
15371537
{
15381538
type Item = T;
15391539

library/alloc/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,4 +284,11 @@ pub(crate) mod test_helpers {
284284
let seed: [u8; 16] = seed_vec.as_slice().try_into().unwrap();
285285
rand::SeedableRng::from_seed(seed)
286286
}
287+
288+
use crate::alloc::Global;
289+
290+
/// See also `core::alloc::co_alloc_metadata_num_slots_with_preference`.
291+
#[unstable(feature = "global_co_alloc", issue = "none")]
292+
pub const fn co_alloc_metadata_num_slots_with_preference_global(coop_preferred: bool) -> usize {
293+
if Global::IS_CO_ALLOCATOR && coop_preferred { 1 } else { 0 }
287294
}

library/alloc/src/raw_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub(crate) struct RawVec<
6969

7070
impl<T, const COOP_PREFERRED: bool> RawVec<T, Global, COOP_PREFERRED>
7171
where
72-
[(); alloc::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
72+
[(); crate::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
7373
{
7474
/// HACK(Centril): This exists because stable `const fn` can only call stable `const fn`, so
7575
/// they cannot call `Self::new()`.

library/alloc/src/rc.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ use crate::boxed::Box;
247247
#[cfg(test)]
248248
use std::boxed::Box;
249249

250-
use crate::alloc;
251250
use core::any::Any;
252251
use core::borrow;
253252
use core::cell::Cell;
@@ -1990,7 +1989,7 @@ impl<T: ?Sized> From<Box<T>> for Rc<T> {
19901989
#[stable(feature = "shared_from_slice", since = "1.21.0")]
19911990
impl<T, const COOP_PREFERRED: bool> From<Vec<T, Global, COOP_PREFERRED>> for Rc<[T]>
19921991
where
1993-
[(); alloc::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
1992+
[(); crate::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
19941993
{
19951994
/// Allocate a reference-counted slice and move `v`'s items into it.
19961995
///
@@ -2005,7 +2004,7 @@ where
20052004
#[inline]
20062005
fn from(mut v: Vec<T, Global, COOP_PREFERRED>) -> Rc<[T]>
20072006
where
2008-
[(); alloc::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
2007+
[(); crate::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
20092008
{
20102009
unsafe {
20112010
let rc = Rc::copy_from_slice(&v);

library/alloc/src/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ where
136136
T: Copy,
137137
B: AsRef<[T]> + ?Sized,
138138
S: Borrow<B>,
139-
[(); alloc::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
139+
[(); crate::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
140140
{
141141
let sep_len = sep.len();
142142
let mut iter = slice.iter();

0 commit comments

Comments
 (0)