Skip to content

Commit b0547ce

Browse files
committed
Move core::alloc::CollectionAllocErr to alloc::collections
1 parent 121b57b commit b0547ce

File tree

9 files changed

+38
-36
lines changed

9 files changed

+38
-36
lines changed

src/liballoc/collections/mod.rs

+29
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,35 @@ pub use self::linked_list::LinkedList;
5151
#[doc(no_inline)]
5252
pub use self::vec_deque::VecDeque;
5353

54+
use alloc::{AllocErr, LayoutErr};
55+
56+
/// Augments `AllocErr` with a CapacityOverflow variant.
57+
#[derive(Clone, PartialEq, Eq, Debug)]
58+
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
59+
pub enum CollectionAllocErr {
60+
/// Error due to the computed capacity exceeding the collection's maximum
61+
/// (usually `isize::MAX` bytes).
62+
CapacityOverflow,
63+
/// Error due to the allocator (see the `AllocErr` type's docs).
64+
AllocErr,
65+
}
66+
67+
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
68+
impl From<AllocErr> for CollectionAllocErr {
69+
#[inline]
70+
fn from(AllocErr: AllocErr) -> Self {
71+
CollectionAllocErr::AllocErr
72+
}
73+
}
74+
75+
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
76+
impl From<LayoutErr> for CollectionAllocErr {
77+
#[inline]
78+
fn from(_: LayoutErr) -> Self {
79+
CollectionAllocErr::CapacityOverflow
80+
}
81+
}
82+
5483
/// An intermediate trait for specialization of `Extend`.
5584
#[doc(hidden)]
5685
trait SpecExtend<I: IntoIterator> {

src/liballoc/collections/vec_deque.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use core::slice;
3030
use core::hash::{Hash, Hasher};
3131
use core::cmp;
3232

33-
use alloc::CollectionAllocErr;
33+
use collections::CollectionAllocErr;
3434
use raw_vec::RawVec;
3535
use vec::Vec;
3636

src/liballoc/raw_vec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use core::ptr::{self, NonNull, Unique};
1818
use core::slice;
1919

2020
use alloc::{Alloc, Layout, Global, handle_alloc_error};
21-
use alloc::CollectionAllocErr;
22-
use alloc::CollectionAllocErr::*;
21+
use collections::CollectionAllocErr;
22+
use collections::CollectionAllocErr::*;
2323
use boxed::Box;
2424

2525
/// A low-level utility for more ergonomically allocating, reallocating, and deallocating

src/liballoc/string.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ use core::ptr;
6666
use core::str::pattern::Pattern;
6767
use core::str::lossy;
6868

69-
use alloc::CollectionAllocErr;
69+
use collections::CollectionAllocErr;
7070
use borrow::{Cow, ToOwned};
7171
use boxed::Box;
7272
use str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars};

src/liballoc/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ use core::ptr;
8080
use core::ptr::NonNull;
8181
use core::slice;
8282

83-
use alloc::CollectionAllocErr;
83+
use collections::CollectionAllocErr;
8484
use borrow::ToOwned;
8585
use borrow::Cow;
8686
use boxed::Box;

src/libcore/alloc.rs

-28
Original file line numberDiff line numberDiff line change
@@ -385,34 +385,6 @@ impl fmt::Display for CannotReallocInPlace {
385385
}
386386
}
387387

388-
/// Augments `AllocErr` with a CapacityOverflow variant.
389-
// FIXME: should this be in libcore or liballoc?
390-
#[derive(Clone, PartialEq, Eq, Debug)]
391-
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
392-
pub enum CollectionAllocErr {
393-
/// Error due to the computed capacity exceeding the collection's maximum
394-
/// (usually `isize::MAX` bytes).
395-
CapacityOverflow,
396-
/// Error due to the allocator (see the `AllocErr` type's docs).
397-
AllocErr,
398-
}
399-
400-
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
401-
impl From<AllocErr> for CollectionAllocErr {
402-
#[inline]
403-
fn from(AllocErr: AllocErr) -> Self {
404-
CollectionAllocErr::AllocErr
405-
}
406-
}
407-
408-
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
409-
impl From<LayoutErr> for CollectionAllocErr {
410-
#[inline]
411-
fn from(_: LayoutErr) -> Self {
412-
CollectionAllocErr::CapacityOverflow
413-
}
414-
}
415-
416388
/// A memory allocator that can be registered as the standard library’s default
417389
/// though the `#[global_allocator]` attributes.
418390
///

src/libstd/collections/hash/map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use self::Entry::*;
1212
use self::VacantEntryState::*;
1313

14-
use alloc::CollectionAllocErr;
14+
use collections::CollectionAllocErr;
1515
use cell::Cell;
1616
use borrow::Borrow;
1717
use cmp::max;

src/libstd/collections/hash/table.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use alloc::{Global, Alloc, Layout, LayoutErr, CollectionAllocErr, handle_alloc_error};
11+
use alloc::{Global, Alloc, Layout, LayoutErr, handle_alloc_error};
12+
use collections::CollectionAllocErr;
1213
use hash::{BuildHasher, Hash, Hasher};
1314
use marker;
1415
use mem::{size_of, needs_drop};

src/libstd/collections/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ pub use self::hash_map::HashMap;
438438
pub use self::hash_set::HashSet;
439439

440440
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
441-
pub use alloc::CollectionAllocErr;
441+
pub use alloc_crate::collections::CollectionAllocErr;
442442

443443
mod hash;
444444

0 commit comments

Comments
 (0)