about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2018-03-28 22:37:37 +0200
committerSimon Sapin <simon.sapin@exyr.org>2018-03-29 14:58:07 +0200
commit94d1970bba87f2d2893f6e934e4c3f02ed50604d (patch)
tree05bdffecb111abc4dbc2b3d888f87b225277159b
parent1169541e173965531de77c15316e83962a7ae39b (diff)
downloadrust-94d1970bba87f2d2893f6e934e4c3f02ed50604d.tar.gz
rust-94d1970bba87f2d2893f6e934e4c3f02ed50604d.zip
Move the alloc::allocator module to core::heap
This is the `Alloc` trait and its dependencies.
-rw-r--r--src/liballoc/heap.rs2
-rw-r--r--src/liballoc/lib.rs7
-rw-r--r--src/libcore/heap.rs (renamed from src/liballoc/allocator.rs)12
-rw-r--r--src/libcore/lib.rs4
-rw-r--r--src/libstd/heap.rs3
5 files changed, 17 insertions, 11 deletions
diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs
index c13ad39e5e1..9296a113071 100644
--- a/src/liballoc/heap.rs
+++ b/src/liballoc/heap.rs
@@ -19,7 +19,7 @@ use core::intrinsics::{min_align_of_val, size_of_val};
 use core::mem::{self, ManuallyDrop};
 use core::usize;
 
-pub use allocator::*;
+pub use core::heap::*;
 #[doc(hidden)]
 pub mod __core {
     pub use core::*;
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index 19d64d8fea9..5594caa65b9 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -81,6 +81,7 @@
 #![cfg_attr(not(test), feature(exact_size_is_empty))]
 #![cfg_attr(not(test), feature(generator_trait))]
 #![cfg_attr(test, feature(rand, test))]
+#![feature(allocator_api)]
 #![feature(allow_internal_unstable)]
 #![feature(ascii_ctype)]
 #![feature(box_into_raw_non_null)]
@@ -145,9 +146,9 @@ extern crate std_unicode;
 #[macro_use]
 mod macros;
 
-// Allocator trait and helper struct definitions
-
-pub mod allocator;
+#[rustc_deprecated(since = "1.27.0", reason = "use the heap module in core, alloc, or std instead")]
+#[unstable(feature = "allocator_api", issue = "32838")]
+pub use core::heap as allocator;
 
 // Heaps provided for low-level allocation strategies
 
diff --git a/src/liballoc/allocator.rs b/src/libcore/heap.rs
index fdc4efc66b9..dae60b1647f 100644
--- a/src/liballoc/allocator.rs
+++ b/src/libcore/heap.rs
@@ -15,11 +15,11 @@
                       tracing garbage collector",
             issue = "32838")]
 
-use core::cmp;
-use core::fmt;
-use core::mem;
-use core::usize;
-use core::ptr::{self, NonNull};
+use cmp;
+use fmt;
+use mem;
+use usize;
+use ptr::{self, NonNull};
 
 /// Represents the combination of a starting address and
 /// a total capacity of the returned block.
@@ -568,7 +568,7 @@ pub unsafe trait Alloc {
     /// invoked method, and let the client decide whether to invoke
     /// this `oom` method in response.
     fn oom(&mut self, _: AllocErr) -> ! {
-        unsafe { ::core::intrinsics::abort() }
+        unsafe { ::intrinsics::abort() }
     }
 
     // == ALLOCATOR-SPECIFIC QUANTITIES AND LIMITS ==
diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index 11fecde3951..c77402ed442 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -185,6 +185,10 @@ pub mod hash;
 pub mod fmt;
 pub mod time;
 
+/* Heap memory allocator trait */
+#[allow(missing_docs)]
+pub mod heap;
+
 // note: does not need to be public
 mod char_private;
 mod iter_private;
diff --git a/src/libstd/heap.rs b/src/libstd/heap.rs
index 4d5e4df6f95..4a391372c3a 100644
--- a/src/libstd/heap.rs
+++ b/src/libstd/heap.rs
@@ -12,8 +12,9 @@
 
 #![unstable(issue = "32838", feature = "allocator_api")]
 
-pub use alloc::heap::{Heap, Alloc, Layout, Excess, CannotReallocInPlace, AllocErr};
+pub use alloc::heap::Heap;
 pub use alloc_system::System;
+pub use core::heap::*;
 
 #[cfg(not(test))]
 #[doc(hidden)]