Skip to content

Commit 6eedad5

Browse files
Moved co_alloc_metadata_num_slots_with_preference_global from ::core::alloc to ::alloc.
1 parent ede511e commit 6eedad5

File tree

9 files changed

+88
-94
lines changed

9 files changed

+88
-94
lines changed

library/alloc/src/boxed.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1687,7 +1687,7 @@ impl<T, const N: usize> TryFrom<Box<[T]>> for Box<[T; N]> {
16871687
impl<T, const N: usize, const COOP_PREFERRED: bool> TryFrom<Vec<T, Global, COOP_PREFERRED>>
16881688
for Box<[T; N]>
16891689
where
1690-
[(); alloc::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
1690+
[(); crate::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
16911691
{
16921692
type Error = Vec<T, Global, COOP_PREFERRED>;
16931693

library/alloc/src/collections/binary_heap.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1480,15 +1480,15 @@ unsafe impl<T: Ord> TrustedLen for IntoIterSorted<T> {}
14801480
#[derive(Debug)]
14811481
pub struct Drain<'a, T: 'a, const COOP_PREFERRED: bool>
14821482
where
1483-
[(); alloc::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
1483+
[(); crate::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
14841484
{
14851485
iter: vec::Drain<'a, T, Global, COOP_PREFERRED>,
14861486
}
14871487

14881488
#[stable(feature = "drain", since = "1.6.0")]
14891489
impl<T, const COOP_PREFERRED: bool> Iterator for Drain<'_, T, COOP_PREFERRED>
14901490
where
1491-
[(); alloc::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
1491+
[(); crate::co_alloc_metadata_num_slots_with_preference_global(COOP_PREFERRED)]:,
14921492
{
14931493
type Item = T;
14941494

library/alloc/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,11 @@ pub mod vec;
261261
pub mod __export {
262262
pub use core::format_args;
263263
}
264+
265+
use crate::alloc::Global;
266+
267+
/// See also `core::alloc::co_alloc_metadata_num_slots_with_preference`.
268+
#[unstable(feature = "global_co_alloc", issue = "none")]
269+
pub const fn co_alloc_metadata_num_slots_with_preference_global(coop_preferred: bool) -> usize {
270+
if Global::IS_CO_ALLOCATOR && coop_preferred { 1 } else { 0 }
271+
}

library/alloc/src/raw_vec.rs

+1-1
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

+2-3
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

+1-1
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)