about summary refs log tree commit diff
path: root/src/libstd/lib.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2017-06-03 14:54:08 -0700
committerAlex Crichton <alex@alexcrichton.com>2017-07-05 14:37:01 -0700
commit695dee063bcd40f154bb27b7beafcb3d4dd775ac (patch)
tree8ac64f40091434e679b4221343dce7447c4f1236 /src/libstd/lib.rs
parent4c225c4d1732537aff63dd97c2b7ac681fd3d188 (diff)
downloadrust-695dee063bcd40f154bb27b7beafcb3d4dd775ac.tar.gz
rust-695dee063bcd40f154bb27b7beafcb3d4dd775ac.zip
rustc: Implement the #[global_allocator] attribute
This PR is an implementation of [RFC 1974] which specifies a new method of
defining a global allocator for a program. This obsoletes the old
`#![allocator]` attribute and also removes support for it.

[RFC 1974]: https://github.com/rust-lang/rfcs/pull/197

The new `#[global_allocator]` attribute solves many issues encountered with the
`#![allocator]` attribute such as composition and restrictions on the crate
graph itself. The compiler now has much more control over the ABI of the
allocator and how it's implemented, allowing much more freedom in terms of how
this feature is implemented.

cc #27389
Diffstat (limited to 'src/libstd/lib.rs')
-rw-r--r--src/libstd/lib.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index bafe23e80a0..c4bdf7c5b82 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -230,11 +230,6 @@
 // Tell the compiler to link to either panic_abort or panic_unwind
 #![needs_panic_runtime]
 
-// Always use alloc_system during stage0 since we don't know if the alloc_*
-// crate the stage0 compiler will pick by default is available (most
-// obviously, if the user has disabled jemalloc in `./configure`).
-#![cfg_attr(any(stage0, feature = "force_alloc_system"), feature(alloc_system))]
-
 // Turn warnings into errors, but only after stage0, where it can be useful for
 // code to emit warnings during language transitions
 #![deny(warnings)]
@@ -246,6 +241,8 @@
 // compiler details that will never be stable
 #![feature(alloc)]
 #![feature(allocator_api)]
+#![feature(alloc_system)]
+#![feature(allocator_internals)]
 #![feature(allow_internal_unstable)]
 #![feature(asm)]
 #![feature(associated_consts)]
@@ -322,6 +319,8 @@
 #![cfg_attr(test, feature(update_panic_count))]
 #![cfg_attr(test, feature(float_bits_conv))]
 
+#![cfg_attr(not(stage0), default_lib_allocator)]
+
 // Explicitly import the prelude. The compiler uses this same unstable attribute
 // to import the prelude implicitly when building crates that depend on std.
 #[prelude_import]
@@ -342,15 +341,13 @@ extern crate core as __core;
 #[macro_use]
 #[macro_reexport(vec, format)]
 extern crate alloc;
+extern crate alloc_system;
 extern crate std_unicode;
 extern crate libc;
 
 // We always need an unwinder currently for backtraces
 extern crate unwind;
 
-#[cfg(any(stage0, feature = "force_alloc_system"))]
-extern crate alloc_system;
-
 // compiler-rt intrinsics
 extern crate compiler_builtins;
 
@@ -465,6 +462,7 @@ pub mod path;
 pub mod process;
 pub mod sync;
 pub mod time;
+pub mod heap;
 
 // Platform-abstraction modules
 #[macro_use]