Move core::alloc::CollectionAllocErr to alloc::collections
This commit is contained in:
parent
121b57b87a
commit
b0547cea0a
@ -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> {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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};
|
||||
|
@ -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;
|
||||
|
@ -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 library’s default
|
||||
/// though the `#[global_allocator]` attributes.
|
||||
///
|
||||
|
@ -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;
|
||||
|
@ -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};
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user