about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2018-06-15 03:56:35 +0200
committerSimon Sapin <simon.sapin@exyr.org>2018-06-29 14:01:33 +0200
commitb0547cea0ae50f49619ded26f43d0d55a1674b14 (patch)
treed8a9e6aabff391b23769efea837aee97a0e44c91
parent121b57b87ae4b58082f38a450373636286a8d678 (diff)
downloadrust-b0547cea0ae50f49619ded26f43d0d55a1674b14.tar.gz
rust-b0547cea0ae50f49619ded26f43d0d55a1674b14.zip
Move core::alloc::CollectionAllocErr to alloc::collections
-rw-r--r--src/liballoc/collections/mod.rs29
-rw-r--r--src/liballoc/collections/vec_deque.rs2
-rw-r--r--src/liballoc/raw_vec.rs4
-rw-r--r--src/liballoc/string.rs2
-rw-r--r--src/liballoc/vec.rs2
-rw-r--r--src/libcore/alloc.rs28
-rw-r--r--src/libstd/collections/hash/map.rs2
-rw-r--r--src/libstd/collections/hash/table.rs3
-rw-r--r--src/libstd/collections/mod.rs2
9 files changed, 38 insertions, 36 deletions
diff --git a/src/liballoc/collections/mod.rs b/src/liballoc/collections/mod.rs
index 35c816a1ceb..96e0eb633b2 100644
--- a/src/liballoc/collections/mod.rs
+++ b/src/liballoc/collections/mod.rs
@@ -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> {
diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs
index 4753d36415c..ba92b886138 100644
--- a/src/liballoc/collections/vec_deque.rs
+++ b/src/liballoc/collections/vec_deque.rs
@@ -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;
 
diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs
index 5095bbe96cc..4f2686abf45 100644
--- a/src/liballoc/raw_vec.rs
+++ b/src/liballoc/raw_vec.rs
@@ -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
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs
index a988b6a26d9..6b28687a060 100644
--- a/src/liballoc/string.rs
+++ b/src/liballoc/string.rs
@@ -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};
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs
index 752a6c966d5..fbbaced540e 100644
--- a/src/liballoc/vec.rs
+++ b/src/liballoc/vec.rs
@@ -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;
diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs
index 91447e01ad4..01221aecb62 100644
--- a/src/libcore/alloc.rs
+++ b/src/libcore/alloc.rs
@@ -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.
 ///
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs
index ee8c1dc81ad..91912e5f241 100644
--- a/src/libstd/collections/hash/map.rs
+++ b/src/libstd/collections/hash/map.rs
@@ -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;
diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs
index d14b754ddb6..2b319186a8d 100644
--- a/src/libstd/collections/hash/table.rs
+++ b/src/libstd/collections/hash/table.rs
@@ -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};
diff --git a/src/libstd/collections/mod.rs b/src/libstd/collections/mod.rs
index 643426c377b..8d2c82bc0aa 100644
--- a/src/libstd/collections/mod.rs
+++ b/src/libstd/collections/mod.rs
@@ -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;