Skip to content

Commit 708a298

Browse files
committed
Remove AbortAlloc
1 parent 819102a commit 708a298

File tree

9 files changed

+120
-208
lines changed

9 files changed

+120
-208
lines changed

CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
# v0.7
22

33
- Add `Vec`
4-
- **Breaking Change**: Change Parameter from `B: BuildAlloc` to `A: DeallocRef` to support type inference
4+
- Add `String`
5+
6+
**Breaking Changes**:
7+
8+
- Change Parameter from `B: BuildAlloc` to `A: DeallocRef` to support type inference
9+
- Require nightly compiler
10+
- Remove `AbortAlloc`
11+
- Remove bound on `Error = !`
512

613
# v0.6
714

src/alloc/abort.rs

-62
This file was deleted.

src/alloc/mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
mod abort;
21
mod layout;
32

4-
pub use self::{
5-
abort::AbortAlloc,
6-
layout::{LayoutErr, NonZeroLayout},
7-
};
3+
pub use self::layout::{LayoutErr, NonZeroLayout};
84
pub use core::alloc::GlobalAlloc;
95
use core::{
106
cmp,

src/boxed.rs

+25-37
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
//! [`NonZeroLayout::for_value(&*value)`]: crate::alloc::NonZeroLayout::for_value
8080
8181
use crate::{
82-
alloc::{AbortAlloc, AllocRef, BuildAllocRef, DeallocRef, Global, NonZeroLayout},
82+
alloc::{AllocRef, BuildAllocRef, DeallocRef, Global, NonZeroLayout},
8383
clone::CloneIn,
8484
collections::CollectionAllocErr,
8585
raw_vec::RawVec,
@@ -105,7 +105,7 @@ use core::{
105105
/// A pointer type for heap allocation.
106106
///
107107
/// See the [module-level documentation](index.html) for more.
108-
pub struct Box<T: ?Sized, A: DeallocRef = AbortAlloc<Global>> {
108+
pub struct Box<T: ?Sized, A: DeallocRef = Global> {
109109
ptr: Unique<T>,
110110
build_alloc: A::BuildAlloc,
111111
}
@@ -131,7 +131,7 @@ impl<T> Box<T> {
131131
#[inline(always)]
132132
#[must_use]
133133
pub fn new(x: T) -> Self {
134-
Self::new_in(x, AbortAlloc(Global))
134+
Self::new_in(x, Global)
135135
}
136136

137137
/// Constructs a new box with uninitialized contents.
@@ -156,7 +156,7 @@ impl<T> Box<T> {
156156
#[inline(always)]
157157
#[must_use]
158158
pub fn new_uninit() -> Box<mem::MaybeUninit<T>> {
159-
Self::new_uninit_in(AbortAlloc(Global))
159+
Self::new_uninit_in(Global)
160160
}
161161

162162
/// Constructs a new `Pin<Box<T>>`. If `T` does not implement `Unpin`, then
@@ -177,19 +177,16 @@ impl<T, A: AllocRef> Box<T, A> {
177177
/// # Example
178178
///
179179
/// ```
180-
/// use alloc_wg::{
181-
/// alloc::{AbortAlloc, Global},
182-
/// boxed::Box,
183-
/// };
180+
/// use alloc_wg::{alloc::Global, boxed::Box};
184181
///
185182
/// # #[allow(unused_variables)]
186-
/// let five = Box::new_in(5, AbortAlloc(Global));
183+
/// let five = Box::new_in(5, Global);
187184
/// ```
188185
#[allow(clippy::inline_always)]
189186
#[inline(always)]
190187
pub fn new_in(x: T, a: A) -> Self
191188
where
192-
A: AllocRef<Error = !>,
189+
A: AllocRef,
193190
{
194191
unsafe { Self::try_new_in(x, a).unwrap_unchecked() }
195192
}
@@ -225,12 +222,9 @@ impl<T, A: AllocRef> Box<T, A> {
225222
/// # Example
226223
///
227224
/// ```
228-
/// use alloc_wg::{
229-
/// alloc::{AbortAlloc, Global},
230-
/// boxed::Box,
231-
/// };
225+
/// use alloc_wg::{alloc::Global, boxed::Box};
232226
///
233-
/// let mut five = Box::<u32, _>::new_uninit_in(AbortAlloc(Global));
227+
/// let mut five = Box::<u32, _>::new_uninit_in(Global);
234228
///
235229
/// let five = unsafe {
236230
/// // Deferred initialization:
@@ -245,7 +239,7 @@ impl<T, A: AllocRef> Box<T, A> {
245239
#[inline(always)]
246240
pub fn new_uninit_in(a: A) -> Box<mem::MaybeUninit<T>, A>
247241
where
248-
A: AllocRef<Error = !>,
242+
A: AllocRef,
249243
{
250244
unsafe { Self::try_new_uninit_in(a).unwrap_unchecked() }
251245
}
@@ -285,7 +279,7 @@ impl<T, A: AllocRef> Box<T, A> {
285279
#[inline(always)]
286280
pub fn pin_in(x: T, a: A) -> Pin<Self>
287281
where
288-
A: AllocRef<Error = !>,
282+
A: AllocRef,
289283
{
290284
unsafe { Self::try_pin_in(x, a).unwrap_unchecked() }
291285
}
@@ -324,7 +318,7 @@ impl<T> Box<[T]> {
324318
#[inline(always)]
325319
#[must_use]
326320
pub fn new_uninit_slice(len: usize) -> Box<[mem::MaybeUninit<T>]> {
327-
Self::new_uninit_slice_in(len, AbortAlloc(Global))
321+
Self::new_uninit_slice_in(len, Global)
328322
}
329323
}
330324

@@ -335,12 +329,9 @@ impl<T, A: AllocRef> Box<[T], A> {
335329
/// # Example
336330
///
337331
/// ```
338-
/// use alloc_wg::{
339-
/// alloc::{AbortAlloc, Global},
340-
/// boxed::Box,
341-
/// };
332+
/// use alloc_wg::{alloc::Global, boxed::Box};
342333
///
343-
/// let mut values = Box::<[u32], AbortAlloc<Global>>::new_uninit_slice_in(3, AbortAlloc(Global));
334+
/// let mut values = Box::<[u32], _>::new_uninit_slice_in(3, Global);
344335
///
345336
/// let values = unsafe {
346337
/// // Deferred initialization:
@@ -357,7 +348,7 @@ impl<T, A: AllocRef> Box<[T], A> {
357348
#[inline(always)]
358349
pub fn new_uninit_slice_in(len: usize, a: A) -> Box<[mem::MaybeUninit<T>], A>
359350
where
360-
A: AllocRef<Error = !>,
351+
A: AllocRef,
361352
{
362353
unsafe { Self::try_new_uninit_slice_in(len, a).unwrap_unchecked() }
363354
}
@@ -524,7 +515,7 @@ impl<T: ?Sized> Box<T> {
524515
#[allow(clippy::inline_always)]
525516
#[inline(always)]
526517
pub unsafe fn from_raw(raw: *mut T) -> Self {
527-
Self::from_raw_in(raw, AbortAlloc(Global))
518+
Self::from_raw_in(raw, Global)
528519
}
529520
}
530521

@@ -768,7 +759,7 @@ unsafe impl<#[may_dangle] T: ?Sized, A: DeallocRef> Drop for Box<T, A> {
768759
impl<T, A> Default for Box<T, A>
769760
where
770761
T: Default,
771-
A: Default + AllocRef<Error = !>,
762+
A: Default + AllocRef,
772763
{
773764
#[must_use]
774765
fn default() -> Self {
@@ -779,7 +770,7 @@ where
779770
#[allow(clippy::use_self)]
780771
impl<T, A> Default for Box<[T], A>
781772
where
782-
A: Default + AllocRef<Error = !>,
773+
A: Default + AllocRef,
783774
{
784775
#[must_use]
785776
fn default() -> Self {
@@ -796,7 +787,7 @@ unsafe fn from_boxed_utf8_unchecked<A: DeallocRef>(v: Box<[u8], A>) -> Box<str,
796787
#[allow(clippy::use_self)]
797788
impl<A> Default for Box<str, A>
798789
where
799-
A: Default + AllocRef<Error = !>,
790+
A: Default + AllocRef,
800791
{
801792
#[must_use]
802793
fn default() -> Self {
@@ -806,7 +797,7 @@ where
806797

807798
impl<T: Clone, A: Clone> Clone for Box<T, A>
808799
where
809-
A: AllocRef<Error = !>,
800+
A: AllocRef,
810801
A::BuildAlloc: Clone,
811802
{
812803
/// Returns a new box with a `clone()` of this box's contents.
@@ -869,7 +860,7 @@ impl<T: Clone, A: AllocRef, B: AllocRef> CloneIn<B> for Box<T, A> {
869860

870861
fn clone_in(&self, a: B) -> Self::Cloned
871862
where
872-
B: AllocRef<Error = !>,
863+
B: AllocRef,
873864
{
874865
Box::new_in(self.as_ref().clone(), a)
875866
}
@@ -973,7 +964,7 @@ impl<T: ?Sized + Hasher, A: DeallocRef> Hasher for Box<T, A> {
973964

974965
impl<T, A> From<T> for Box<T, A>
975966
where
976-
A: Default + AllocRef<Error = !>,
967+
A: Default + AllocRef,
977968
{
978969
/// Converts a generic type `T` into a `Box<T>`
979970
///
@@ -1007,7 +998,7 @@ impl<T: ?Sized, A: DeallocRef> From<Box<T, A>> for Pin<Box<T, A>> {
1007998
#[allow(clippy::use_self)]
1008999
impl<T: Copy, A> From<&[T]> for Box<[T], A>
10091000
where
1010-
A: Default + AllocRef<Error = !>,
1001+
A: Default + AllocRef,
10111002
{
10121003
/// Converts a `&[T]` into a `Box<[T], B>`
10131004
///
@@ -1036,7 +1027,7 @@ where
10361027
#[allow(clippy::use_self)]
10371028
impl<A> From<&str> for Box<str, A>
10381029
where
1039-
A: Default + AllocRef<Error = !>,
1030+
A: Default + AllocRef,
10401031
{
10411032
/// Converts a `&str` into a `Box<str>`
10421033
///
@@ -1290,16 +1281,13 @@ macro_rules! impl_dispatch_from_dyn {
12901281
}
12911282

12921283
impl_dispatch_from_dyn!(Global);
1293-
impl_dispatch_from_dyn!(AbortAlloc<Global>);
12941284
#[cfg(feature = "std")]
12951285
impl_dispatch_from_dyn!(std::alloc::System);
1296-
#[cfg(feature = "std")]
1297-
impl_dispatch_from_dyn!(AbortAlloc<std::alloc::System>);
12981286

12991287
#[allow(clippy::items_after_statements)]
13001288
impl<T: Clone, A: Clone> Clone for Box<[T], A>
13011289
where
1302-
A: AllocRef<Error = !>,
1290+
A: AllocRef,
13031291
A::BuildAlloc: Clone,
13041292
{
13051293
fn clone(&self) -> Self {

src/clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub trait CloneIn<A: AllocRef>: Sized {
55

66
fn clone_in(&self, a: A) -> Self::Cloned
77
where
8-
A: AllocRef<Error = !>;
8+
A: AllocRef;
99

1010
fn try_clone_in(&self, a: A) -> Result<Self::Cloned, A::Error>;
1111
}

src/iter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub trait TryExtend<A> {
1717
/// message.try_extend(['d', 'e', 'f'].iter())?;
1818
///
1919
/// assert_eq!(vec!['a', 'b', 'c', 'd', 'e', 'f'], message);
20-
/// # Ok::<(), alloc_wg::collections::CollectionAllocErr<alloc_wg::alloc::AbortAlloc<alloc_wg::alloc::Global>>>(())
20+
/// # Ok::<(), alloc_wg::collections::CollectionAllocErr<alloc_wg::alloc::Global>>(())
2121
/// ```
2222
fn try_extend<T: IntoIterator<Item = A>>(&mut self, iter: T) -> Result<(), Self::Err>;
2323
}

0 commit comments

Comments
 (0)