Move core::alloc::CollectionAllocErr to alloc::collections

This commit is contained in:
Simon Sapin 2018-06-15 03:56:35 +02:00
parent 121b57b87a
commit b0547cea0a
9 changed files with 38 additions and 36 deletions

View File

@ -51,6 +51,35 @@ pub use self::linked_list::LinkedList;
#[doc(no_inline)]
pub use self::vec_deque::VecDeque;
use alloc::{AllocErr, LayoutErr};
/// Augments `AllocErr` with a CapacityOverflow variant.
#[derive(Clone, PartialEq, Eq, Debug)]
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
pub enum CollectionAllocErr {
/// Error due to the computed capacity exceeding the collection's maximum
/// (usually `isize::MAX` bytes).
CapacityOverflow,
/// Error due to the allocator (see the `AllocErr` type's docs).
AllocErr,
}
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
impl From<AllocErr> for CollectionAllocErr {
#[inline]
fn from(AllocErr: AllocErr) -> Self {
CollectionAllocErr::AllocErr
}
}
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
impl From<LayoutErr> for CollectionAllocErr {
#[inline]
fn from(_: LayoutErr) -> Self {
CollectionAllocErr::CapacityOverflow
}
}
/// An intermediate trait for specialization of `Extend`.
#[doc(hidden)]
trait SpecExtend<I: IntoIterator> {

View File

@ -30,7 +30,7 @@ use core::slice;
use core::hash::{Hash, Hasher};
use core::cmp;
use alloc::CollectionAllocErr;
use collections::CollectionAllocErr;
use raw_vec::RawVec;
use vec::Vec;

View File

@ -18,8 +18,8 @@ use core::ptr::{self, NonNull, Unique};
use core::slice;
use alloc::{Alloc, Layout, Global, handle_alloc_error};
use alloc::CollectionAllocErr;
use alloc::CollectionAllocErr::*;
use collections::CollectionAllocErr;
use collections::CollectionAllocErr::*;
use boxed::Box;
/// A low-level utility for more ergonomically allocating, reallocating, and deallocating

View File

@ -66,7 +66,7 @@ use core::ptr;
use core::str::pattern::Pattern;
use core::str::lossy;
use alloc::CollectionAllocErr;
use collections::CollectionAllocErr;
use borrow::{Cow, ToOwned};
use boxed::Box;
use str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars};

View File

@ -80,7 +80,7 @@ use core::ptr;
use core::ptr::NonNull;
use core::slice;
use alloc::CollectionAllocErr;
use collections::CollectionAllocErr;
use borrow::ToOwned;
use borrow::Cow;
use boxed::Box;

View File

@ -385,34 +385,6 @@ impl fmt::Display for CannotReallocInPlace {
}
}
/// Augments `AllocErr` with a CapacityOverflow variant.
// FIXME: should this be in libcore or liballoc?
#[derive(Clone, PartialEq, Eq, Debug)]
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
pub enum CollectionAllocErr {
/// Error due to the computed capacity exceeding the collection's maximum
/// (usually `isize::MAX` bytes).
CapacityOverflow,
/// Error due to the allocator (see the `AllocErr` type's docs).
AllocErr,
}
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
impl From<AllocErr> for CollectionAllocErr {
#[inline]
fn from(AllocErr: AllocErr) -> Self {
CollectionAllocErr::AllocErr
}
}
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
impl From<LayoutErr> for CollectionAllocErr {
#[inline]
fn from(_: LayoutErr) -> Self {
CollectionAllocErr::CapacityOverflow
}
}
/// A memory allocator that can be registered as the standard librarys default
/// though the `#[global_allocator]` attributes.
///

View File

@ -11,7 +11,7 @@
use self::Entry::*;
use self::VacantEntryState::*;
use alloc::CollectionAllocErr;
use collections::CollectionAllocErr;
use cell::Cell;
use borrow::Borrow;
use cmp::max;

View File

@ -8,7 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use alloc::{Global, Alloc, Layout, LayoutErr, CollectionAllocErr, handle_alloc_error};
use alloc::{Global, Alloc, Layout, LayoutErr, handle_alloc_error};
use collections::CollectionAllocErr;
use hash::{BuildHasher, Hash, Hasher};
use marker;
use mem::{size_of, needs_drop};

View File

@ -438,7 +438,7 @@ pub use self::hash_map::HashMap;
pub use self::hash_set::HashSet;
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
pub use alloc::CollectionAllocErr;
pub use alloc_crate::collections::CollectionAllocErr;
mod hash;