diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2018-04-03 21:15:06 +0200 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2018-04-12 22:52:47 +0200 |
| commit | e521b8b472dfe058f6d0f62f2e1ab5f291c220ee (patch) | |
| tree | b7bd74b0b572fc7143fd783a6e912b4d1ebbf1cc /src/libstd | |
| parent | 88ebd2d752831860d8824849cf6f5ae656a2c3eb (diff) | |
| download | rust-e521b8b472dfe058f6d0f62f2e1ab5f291c220ee.tar.gz rust-e521b8b472dfe058f6d0f62f2e1ab5f291c220ee.zip | |
Actually deprecate the Heap type
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/alloc.rs | 3 | ||||
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 4 | ||||
| -rw-r--r-- | src/libstd/collections/hash/table.rs | 12 |
3 files changed, 10 insertions, 9 deletions
diff --git a/src/libstd/alloc.rs b/src/libstd/alloc.rs index 77be3e52d76..eb0c960732d 100644 --- a/src/libstd/alloc.rs +++ b/src/libstd/alloc.rs @@ -12,7 +12,8 @@ #![unstable(issue = "32838", feature = "allocator_api")] -#[doc(inline)] pub use alloc_crate::alloc::Heap; +#[doc(inline)] #[allow(deprecated)] pub use alloc_crate::alloc::Heap; +#[doc(inline)] pub use alloc_crate::alloc::Global; #[doc(inline)] pub use alloc_system::System; #[doc(inline)] pub use core::alloc::*; diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 73a5df8dc28..c4ef9e62577 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -11,13 +11,13 @@ use self::Entry::*; use self::VacantEntryState::*; +use alloc::{Global, Alloc, CollectionAllocErr}; use cell::Cell; use borrow::Borrow; use cmp::max; use fmt::{self, Debug}; #[allow(deprecated)] use hash::{Hash, Hasher, BuildHasher, SipHasher13}; -use heap::{Heap, Alloc, CollectionAllocErr}; use iter::{FromIterator, FusedIterator}; use mem::{self, replace}; use ops::{Deref, Index}; @@ -784,7 +784,7 @@ impl<K, V, S> HashMap<K, V, S> pub fn reserve(&mut self, additional: usize) { match self.try_reserve(additional) { Err(CollectionAllocErr::CapacityOverflow) => panic!("capacity overflow"), - Err(CollectionAllocErr::AllocErr(e)) => Heap.oom(e), + Err(CollectionAllocErr::AllocErr(e)) => Global.oom(e), Ok(()) => { /* yay */ } } } diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs index 878cd82a258..10bab5df8b5 100644 --- a/src/libstd/collections/hash/table.rs +++ b/src/libstd/collections/hash/table.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use alloc::{Global, Alloc, Layout, CollectionAllocErr}; use cmp; use hash::{BuildHasher, Hash, Hasher}; -use heap::{Heap, Alloc, Layout, CollectionAllocErr}; use marker; use mem::{align_of, size_of, needs_drop}; use mem; @@ -754,7 +754,7 @@ impl<K, V> RawTable<K, V> { return Err(CollectionAllocErr::CapacityOverflow); } - let buffer = Heap.alloc(Layout::from_size_align(size, alignment) + let buffer = Global.alloc(Layout::from_size_align(size, alignment) .ok_or(CollectionAllocErr::CapacityOverflow)?)?; let hashes = buffer as *mut HashUint; @@ -772,7 +772,7 @@ impl<K, V> RawTable<K, V> { unsafe fn new_uninitialized(capacity: usize) -> RawTable<K, V> { match Self::try_new_uninitialized(capacity) { Err(CollectionAllocErr::CapacityOverflow) => panic!("capacity overflow"), - Err(CollectionAllocErr::AllocErr(e)) => Heap.oom(e), + Err(CollectionAllocErr::AllocErr(e)) => Global.oom(e), Ok(table) => { table } } } @@ -811,7 +811,7 @@ impl<K, V> RawTable<K, V> { pub fn new(capacity: usize) -> RawTable<K, V> { match Self::try_new(capacity) { Err(CollectionAllocErr::CapacityOverflow) => panic!("capacity overflow"), - Err(CollectionAllocErr::AllocErr(e)) => Heap.oom(e), + Err(CollectionAllocErr::AllocErr(e)) => Global.oom(e), Ok(table) => { table } } } @@ -1185,8 +1185,8 @@ unsafe impl<#[may_dangle] K, #[may_dangle] V> Drop for RawTable<K, V> { debug_assert!(!oflo, "should be impossible"); unsafe { - Heap.dealloc(self.hashes.ptr() as *mut u8, - Layout::from_size_align(size, align).unwrap()); + Global.dealloc(self.hashes.ptr() as *mut u8, + Layout::from_size_align(size, align).unwrap()); // Remember how everything was allocated out of one buffer // during initialization? We only need one call to free here. } |
