Skip to content

Commit 60a5074

Browse files
CoAlloc: Fixed my previous bug in Vec's IntoIter::clone(). Cleanup for the next rebase.
1 parent 7fe4d21 commit 60a5074

File tree

6 files changed

+30
-33
lines changed

6 files changed

+30
-33
lines changed

library/alloc/src/collections/btree/node.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,6 @@ struct LeafNode<K, V> {
7979
vals: [MaybeUninit<V>; leaf_node_capacity!()],
8080
}
8181

82-
/// @FIXME Remove once we remove leaf_node_capacity!() workaround for https://github.com/rust-lang/rust/issues/108751
83-
/// This should be in #[test], but that would mean having it in a separate file (as per `x test tidy --bless`) - too complicated for this workaround.
84-
#[allow(dead_code)]
85-
fn assert_leaf_node_capacity() {
86-
fn leaf_node() -> LeafNode<char, bool> {
87-
loop {}
88-
}
89-
let node = leaf_node();
90-
let _keys: [MaybeUninit<char>; CAPACITY] = node.keys;
91-
let _vals: [MaybeUninit<bool>; CAPACITY] = node.vals;
92-
}
93-
9482
impl<K, V> LeafNode<K, V> {
9583
/// Initializes a new `LeafNode` in-place.
9684
unsafe fn init(this: *mut Self) {
@@ -129,17 +117,6 @@ struct InternalNode<K, V> {
129117
edges: [MaybeUninit<BoxedNode<K, V>>; internal_node_capacity!()], // @FIXME internal_node_capacity!() workaround for https://github.com/rust-lang/rust/issues/108751
130118
}
131119

132-
/// @FIXME Remove once we remove internal_node_capacity!() workaround for https://github.com/rust-lang/rust/issues/108751
133-
/// This should be in #[test], but that would mean having it in a separate file (as per `x test tidy --bless`) - too complicated for this workaround.
134-
#[allow(dead_code)]
135-
fn assert_internal_node_capacity() {
136-
fn internal_node() -> InternalNode<char, bool> {
137-
loop {}
138-
}
139-
let node = internal_node();
140-
let _edges: [MaybeUninit<BoxedNode<char, bool>>; 2 * B] = node.edges;
141-
}
142-
143120
impl<K, V> InternalNode<K, V> {
144121
/// Creates a new boxed `InternalNode`.
145122
///

library/alloc/src/raw_vec.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,10 @@ impl<T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> RawVec<T, A, CO_ALLOC_PR
126126
where
127127
[(); { crate::meta_num_slots!(A, CO_ALLOC_PREF) }]:,
128128
{
129+
// @FIXME
129130
#[allow(dead_code)]
130131
const fn new_plain_metas() -> [A::CoAllocMeta; { meta_num_slots_default!(A) }] {
131-
loop {}
132+
panic!("FIXME")
132133
}
133134

134135
// Tiny Vecs are dumb. Skip to:

library/alloc/src/vec/into_iter.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -455,13 +455,13 @@ where
455455
#[cfg(not(test))]
456456
fn clone(&self) -> Self {
457457
// @FIXME Remove the following extras - used for type checks only
458-
let slice = self.as_slice();
459-
let vec: crate::vec::Vec<T, A, CO_ALLOC_PREF> =
460-
slice.to_vec_in_co::<A, CO_ALLOC_PREF>(self.alloc.deref().clone());
461-
let _iter: IntoIter<T, A, CO_ALLOC_PREF> = vec.into_iter();
462-
463-
//self.as_slice().to_vec_in::<A, CO_ALLOC_PREF>(self.alloc.deref().clone()).into_iter()
464-
loop {}
458+
if false {
459+
let slice = self.as_slice();
460+
let vec: crate::vec::Vec<T, A, CO_ALLOC_PREF> =
461+
slice.to_vec_in_co::<A, CO_ALLOC_PREF>(self.alloc.deref().clone());
462+
let _iter: IntoIter<T, A, CO_ALLOC_PREF> = vec.into_iter();
463+
}
464+
self.as_slice().to_vec_in_co::<A, CO_ALLOC_PREF>(self.alloc.deref().clone()).into_iter()
465465
}
466466
#[cfg(test)]
467467
fn clone(&self) -> Self {

library/alloc/src/vec/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3160,7 +3160,7 @@ where
31603160
where
31613161
R: RangeBounds<usize>,
31623162
I: IntoIterator<Item = T>,
3163-
[(); { crate::meta_num_slots!(A, crate::CO_ALLOC_PREF_META_YES!()) }]:,
3163+
[(); CO_ALLOC_PREF]:,
31643164
{
31653165
Splice { drain: self.drain(range), replace_with: replace_with.into_iter() }
31663166
}

library/core/src/iter/adapters/peekable.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ pub struct Peekable<I: Iterator> {
1818
peeked: Option<Option<I::Item>>,
1919
}
2020

21+
/*
22+
#[stable(feature = "rust1", since = "1.0.0")]
23+
impl<I: Iterator + Clone> Clone for Peekable<I>
24+
where I::Item : Clone {
25+
fn clone(&self) -> Self {
26+
dbg_printf!("Peekable::clone() started".as_bytes().as_ptr());
27+
let ic= self.iter.clone();
28+
dbg_printf!("self.iter cloned successfully.".as_bytes().as_ptr());
29+
let pc= self.peeked.clone();
30+
dbg_printf!("self.peeked cloned successfully.".as_bytes().as_ptr());
31+
32+
Self {
33+
iter: ic, //self.iter.clone(),
34+
peeked: pc //self.peeked.clone()
35+
}
36+
}
37+
}*/
38+
2139
impl<I: Iterator> Peekable<I> {
2240
pub(in crate::iter) fn new(iter: I) -> Peekable<I> {
2341
Peekable { iter, peeked: None }

tests/ui/allocator/object-safe.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
//use std::alloc::{Allocator, System};
88

9-
// PK: nowhere else under rust source, only here:
9+
// @FIXME
10+
// peter-kehl: nowhere else under rust source, only here:
1011
//fn ensure_object_safe(_: &dyn Allocator) {}
1112

1213
fn main() {

0 commit comments

Comments
 (0)