Skip to content

Commit a93b530

Browse files
CoAlloc: Fixed specializations
1 parent 45518cd commit a93b530

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

library/alloc/src/co_alloc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
/// - DO NOT hard code any values; and
2222
/// - DO NOT mix this/cast this with/to `u8`, `u16`, `usize` (nor any other integer).
2323
#[unstable(feature = "global_co_alloc_meta", issue = "none")]
24-
pub type CoAllocPref = u8;
24+
pub type CoAllocPref = usize; //u8;
2525

26-
/// `CoAllocMetaNumSlotsPref` values indicate a type (but not an allocator) prefers to coallocate by
27-
/// carrying metadata, or not. (In either user space, or `std` space). Used as an argument to macro
28-
/// call of `co_alloc_pref`, which generates a `CoAllocPref` value.
26+
/// `CoAllocMetaNumSlotsPref` values indicate that a type (but not necessarily an allocator) prefers
27+
/// to coallocate by carrying metadata, or not. (In either user space, or `std` or `alloc` space).
28+
/// Used as an argument to macro call of `co_alloc_pref`, which generates a `CoAllocPref` value.
2929
///
3030
/// Currently this indicates only the (preferred) number of `CoAllocMetaBase` slots being used
3131
/// (either 1 = coallocation, or 0 = no coallocation). However, in the future this type may have

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub(super) trait SpecFromIterCo<T, I> {
1212
fn spec_from_iter_co(iter: I) -> Self;
1313
}
1414

15-
#[allow(unused_braces)]
1615
impl<T, I> SpecFromIter<T, I> for VecDeque<T>
1716
where
1817
I: Iterator<Item = T>,
@@ -26,15 +25,13 @@ where
2625
}
2726
}
2827

29-
#[allow(unused_braces)]
3028
impl<T> SpecFromIter<T, crate::vec::IntoIter<T>> for VecDeque<T> {
3129
#[inline]
3230
fn spec_from_iter(iterator: crate::vec::IntoIter<T>) -> Self {
3331
iterator.into_vecdeque()
3432
}
3533
}
3634

37-
#[allow(unused_braces)]
3835
impl<T> SpecFromIter<T, IntoIter<T>> for VecDeque<T> {
3936
#[inline]
4037
fn spec_from_iter(iterator: IntoIter<T>) -> Self {

library/alloc/src/slice.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,10 @@ impl<T> [T] {
627627
#[rustc_allow_incoherent_impl]
628628
#[stable(feature = "rust1", since = "1.0.0")]
629629
#[inline]
630-
pub fn into_vec<A: Allocator>(self: Box<Self, A>) -> Vec<T, A> {
630+
#[allow(unused_braces)]
631+
pub fn into_vec<A: Allocator>(self: Box<Self, A>) -> Vec<T, A>
632+
where [(); { crate::meta_num_slots!(A, CO_ALLOC_PREF) }]:
633+
{
631634
// N.B., see the `hack` module in this file for more details.
632635
hack::into_vec(self)
633636
}
@@ -981,12 +984,18 @@ where
981984
// public in the crate and has the Allocator parameter so that
982985
// vec::clone_from use it too.
983986
#[cfg(not(no_global_oom_handling))]
984-
pub(crate) trait SpecCloneIntoVec<T, A: Allocator> {
987+
#[allow(unused_braces)]
988+
pub(crate) trait SpecCloneIntoVec<T, A: Allocator>
989+
where [(); { crate::meta_num_slots!(A, CO_ALLOC_PREF) }]:
990+
{
985991
fn clone_into(&self, target: &mut Vec<T, A>);
986992
}
987993

988994
#[cfg(not(no_global_oom_handling))]
989-
impl<T: Clone, A: Allocator> SpecCloneIntoVec<T, A> for [T] {
995+
#[allow(unused_braces)]
996+
impl<T: Clone, A: Allocator> SpecCloneIntoVec<T, A> for [T]
997+
where [(); { crate::meta_num_slots!(A, CO_ALLOC_PREF) }]:
998+
{
990999
default fn clone_into(&self, target: &mut Vec<T, A>) {
9911000
// drop anything in target that will not be overwritten
9921001
target.truncate(self.len());
@@ -1002,7 +1011,10 @@ impl<T: Clone, A: Allocator> SpecCloneIntoVec<T, A> for [T] {
10021011
}
10031012

10041013
#[cfg(not(no_global_oom_handling))]
1005-
impl<T: Copy, A: Allocator> SpecCloneIntoVec<T, A> for [T] {
1014+
#[allow(unused_braces)]
1015+
impl<T: Copy, A: Allocator> SpecCloneIntoVec<T, A> for [T]
1016+
where [(); { crate::meta_num_slots!(A, CO_ALLOC_PREF) }]:
1017+
{
10061018
fn clone_into(&self, target: &mut Vec<T, A>) {
10071019
target.clear();
10081020
target.extend_from_slice(self);

library/core/src/alloc/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ impl const CoAllocMetaBase for CoAllocMetaPlain {
106106
/// `#![feature(adt_const_params)]` are stable) to a dedicated struct/enum. Hence:
107107
/// - DO NOT mix this/cast this with/to `u8`, `u16`, (nor any other integer); and
108108
/// - DO NOT hard code any values, but use `CO_ALLOCATOR_SUPPORTS_META_YES` and `CO_ALLOCATOR_SUPPORTS_META_NO`.
109-
///
109+
// @FIXME Once ICE is fixed: Change to `u32` (or any other unused unsinged integer type, and other
110+
// than `usize`, so we can't mix it up with `usize`).
110111
#[unstable(feature = "global_co_alloc_meta", issue = "none")]
111-
pub type CoAllocatorMetaNumSlots = u32;
112+
pub type CoAllocatorMetaNumSlots = usize;
112113

113114
/// Indicating that an Allocator supports coallocation (if a type of the allocated instances supports it, too).
114115
#[unstable(feature = "global_co_alloc_meta", issue = "none")]

0 commit comments

Comments
 (0)