Skip to content

Commit 45a565c

Browse files
CoAlloc: Tiny fixes.
1 parent 7b145a8 commit 45a565c

File tree

9 files changed

+15
-33
lines changed

9 files changed

+15
-33
lines changed

library/alloc/src/boxed.rs

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
147147
#![stable(feature = "rust1", since = "1.0.0")]
148148

149+
#[cfg(not(no_global_oom_handling))]
149150
use crate::co_alloc::CoAllocPref;
150151
use core::any::Any;
151152
use core::async_iter::AsyncIterator;

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

+5-8
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,8 @@ impl<T, const CO_ALLOC_PREF: CoAllocPref> VecDeque<T, Global, CO_ALLOC_PREF>
607607
where
608608
[(); { crate::meta_num_slots_global!(CO_ALLOC_PREF) }]:,
609609
{
610-
/// Coallocation-aware version of `new`.
610+
// @FIXME intra-doc ref.
611+
/// Coallocation-aware version of [VecDeque<T,>::new()].
611612
#[inline]
612613
#[unstable(feature = "co_alloc_global", issue = "none")]
613614
#[must_use]
@@ -617,7 +618,8 @@ where
617618
VecDeque { head: 0, len: 0, buf: RawVec::NEW }
618619
}
619620

620-
/// Coallocation-aware version of `with_capacity`.
621+
// @FIXME intra-doc ref.
622+
/// Coallocation-aware version of [VecDeque<T,>::with_capacity()].
621623
#[inline]
622624
#[stable(feature = "rust1", since = "1.0.0")]
623625
#[must_use]
@@ -2872,12 +2874,7 @@ impl<T, const CO_ALLOC_PREF: CoAllocPref> VecDeque<T, Global, CO_ALLOC_PREF>
28722874
where
28732875
[(); { crate::meta_num_slots_global!(CO_ALLOC_PREF) }]:,
28742876
{
2875-
/// Like `<VecDeque::<T>>::from_iter()`, but coallocation-aware.
2876-
/// Like [`VecDeque::<T>::from_iter()`], but coallocation-aware.
2877-
/// Like [`<VecDeque::<T>>::from_iter(I)`], but coallocation-aware.
2878-
/// Like [`VecDeque::<T>::from_iter(I)`], but coallocation-aware.
2879-
/// Like [`<VecDeque::<T>>::from_iter(I: IntoIterator<Item = T>)`], but coallocation-aware.
2880-
/// Like [`VecDeque::<T>::from_iter(I: IntoIterator<Item = T>)`], but coallocation-aware.
2877+
/// Coallocation-aware version of [VecDeque<T,>::from_iter()].
28812878
pub fn from_iter_co<I: IntoIterator<Item = T>>(iter: I) -> VecDeque<T, Global, CO_ALLOC_PREF> {
28822879
SpecFromIterCo::spec_from_iter_co(iter.into_iter())
28832880
}

library/alloc/src/rc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ use crate::alloc::handle_alloc_error;
275275
use crate::alloc::{box_free, WriteCloneIntoRaw};
276276
use crate::alloc::{AllocError, Allocator, Global, Layout};
277277
use crate::borrow::{Cow, ToOwned};
278+
#[cfg(not(no_global_oom_handling))]
278279
use crate::co_alloc::CoAllocPref;
279280
#[cfg(not(no_global_oom_handling))]
280281
use crate::string::String;

library/alloc/src/slice.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -644,12 +644,7 @@ impl<T> [T] {
644644
hack::into_vec(self)
645645
}
646646

647-
/// Coallocation-aware version of `into_vec<A>()`.
648-
/// Coallocation-aware version of `into_vec::<A>()`.
649-
/// Coallocation-aware version of [`into_vec<A>(self)`].
650-
/// Coallocation-aware version of [`into_vec::<A>(self)`].
651-
/// Coallocation-aware version of [`into_vec<A>(Box<Self, A>)`].
652-
/// Coallocation-aware version of [`into_vec::<A>(Box<Self, A>)`].
647+
/// Coallocation-aware version of [\[T\]::into_vec()].
653648
#[rustc_allow_incoherent_impl]
654649
#[unstable(feature = "global_co_alloc", issue = "none")]
655650
#[inline]

library/alloc/src/vec/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -908,22 +908,22 @@ impl<T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> Vec<T, A, CO_ALLOC_PREF>
908908
where
909909
[(); { crate::meta_num_slots!(A, CO_ALLOC_PREF) }]:,
910910
{
911-
/** Like `new_in`, but co-allocation-aware. */
911+
/// Coallocation-aware version of [Vec<T,A>::new_in()].
912912
#[inline]
913913
#[unstable(feature = "global_co_alloc", issue = "none")]
914914
pub const fn new_in_co(alloc: A) -> Self {
915915
Vec { buf: RawVec::new_in(alloc), len: 0 }
916916
}
917917

918-
/** Like `with_capacity_in`, but co-allocation-aware. */
918+
/// Coallocation-aware version of [Vec<T,A>::with_capacity_in()].
919919
#[cfg(not(no_global_oom_handling))]
920920
#[inline]
921921
#[unstable(feature = "global_co_alloc", issue = "none")]
922922
pub fn with_capacity_in_co(capacity: usize, alloc: A) -> Self {
923923
Vec { buf: RawVec::with_capacity_in(capacity, alloc), len: 0 }
924924
}
925925

926-
/** Like `from_raw_parts_in`, but co-allocation-aware. */
926+
/// Coallocation-aware version of [Vec<T,A>::from_raw_parts_in()].
927927
#[inline]
928928
#[unstable(feature = "global_co_alloc", issue = "none")]
929929
pub unsafe fn from_raw_parts_in_co(

library/std/src/sys/hermit/thread_local_dtor.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#![cfg(target_thread_local)]
22
#![unstable(feature = "thread_local_internals", issue = "none")]
3-
#![feature(global_co_alloc_plvec)]
43

54
// Simplify dtor registration by using a list of destructors.
65
// The this solution works like the implementation of macOS and
76
// doesn't additional OS support
87

98
use crate::mem;
10-
use core::alloc::PlVec;
9+
use alloc::vec::PlVec;
1110

1211
#[thread_local]
1312
static mut DTORS: PlVec<(*mut u8, unsafe extern "C" fn(*mut u8))> = PlVec::new();

library/std/src/sys/solid/thread_local_dtor.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
#![cfg(target_thread_local)]
22
#![unstable(feature = "thread_local_internals", issue = "none")]
3-
#![feature(global_co_alloc_plvec)]
4-
#![feature(global_co_alloc_plvec)]
53

64
// Simplify dtor registration by using a list of destructors.
75

86
use super::{abi, itron::task};
97
use crate::cell::Cell;
108
use crate::mem;
11-
use core::alloc::PlVec;
9+
use alloc::vec::PlVec;
1210

1311
#[thread_local]
1412
static REGISTERED: Cell<bool> = Cell::new(false);

library/std/src/sys/unix/thread_local_dtor.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
5353
use crate::cell::Cell;
5454
use crate::mem;
5555
use crate::ptr;
56+
use alloc::vec::PlVec;
5657

5758
#[thread_local]
5859
static REGISTERED: Cell<bool> = Cell::new(false);
@@ -65,15 +66,6 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
6566
REGISTERED.set(true);
6667
}
6768

68-
type List = alloc::vec::PlVec<(*mut u8, unsafe extern "C" fn(*mut u8))>;
69-
70-
#[thread_local]
71-
static DTORS: Cell<*mut List> = Cell::new(ptr::null_mut());
72-
if DTORS.get().is_null() {
73-
let v: Box<List> = Box::new(Vec::new());
74-
DTORS.set(Box::into_raw(v));
75-
}
76-
7769
extern "C" {
7870
fn _tlv_atexit(dtor: unsafe extern "C" fn(*mut u8), arg: *mut u8);
7971
}

library/std/src/sys/windows/thread_local_dtor.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
44
#![unstable(feature = "thread_local_internals", issue = "none")]
55
#![cfg(target_thread_local)]
6-
#![feature(global_co_alloc_plvec)]
76

8-
use core::alloc::PlVec;
7+
use alloc::vec::PlVec;
98

109
// Using a per-thread list avoids the problems in synchronizing global state.
1110
#[thread_local]

0 commit comments

Comments
 (0)