1
Fork 0

Auto merge of #49481 - SimonSapin:core-heap, r=alexcrichton

Move the alloc::allocator module to core::heap

This is the `Alloc` trait and its dependencies.
This commit is contained in:
bors 2018-03-31 09:11:21 +00:00
commit 8dd24c8ed4
5 changed files with 17 additions and 11 deletions

View file

@ -19,7 +19,7 @@ use core::intrinsics::{min_align_of_val, size_of_val};
use core::mem::{self, ManuallyDrop}; use core::mem::{self, ManuallyDrop};
use core::usize; use core::usize;
pub use allocator::*; pub use core::heap::*;
#[doc(hidden)] #[doc(hidden)]
pub mod __core { pub mod __core {
pub use core::*; pub use core::*;

View file

@ -81,6 +81,7 @@
#![cfg_attr(not(test), feature(exact_size_is_empty))] #![cfg_attr(not(test), feature(exact_size_is_empty))]
#![cfg_attr(not(test), feature(generator_trait))] #![cfg_attr(not(test), feature(generator_trait))]
#![cfg_attr(test, feature(rand, test))] #![cfg_attr(test, feature(rand, test))]
#![feature(allocator_api)]
#![feature(allow_internal_unstable)] #![feature(allow_internal_unstable)]
#![feature(ascii_ctype)] #![feature(ascii_ctype)]
#![feature(box_into_raw_non_null)] #![feature(box_into_raw_non_null)]
@ -146,9 +147,9 @@ extern crate std_unicode;
#[macro_use] #[macro_use]
mod macros; mod macros;
// Allocator trait and helper struct definitions #[rustc_deprecated(since = "1.27.0", reason = "use the heap module in core, alloc, or std instead")]
#[unstable(feature = "allocator_api", issue = "32838")]
pub mod allocator; pub use core::heap as allocator;
// Heaps provided for low-level allocation strategies // Heaps provided for low-level allocation strategies

View file

@ -15,11 +15,11 @@
tracing garbage collector", tracing garbage collector",
issue = "32838")] issue = "32838")]
use core::cmp; use cmp;
use core::fmt; use fmt;
use core::mem; use mem;
use core::usize; use usize;
use core::ptr::{self, NonNull}; use ptr::{self, NonNull};
/// Represents the combination of a starting address and /// Represents the combination of a starting address and
/// a total capacity of the returned block. /// 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 /// invoked method, and let the client decide whether to invoke
/// this `oom` method in response. /// this `oom` method in response.
fn oom(&mut self, _: AllocErr) -> ! { fn oom(&mut self, _: AllocErr) -> ! {
unsafe { ::core::intrinsics::abort() } unsafe { ::intrinsics::abort() }
} }
// == ALLOCATOR-SPECIFIC QUANTITIES AND LIMITS == // == ALLOCATOR-SPECIFIC QUANTITIES AND LIMITS ==

View file

@ -186,6 +186,10 @@ pub mod hash;
pub mod fmt; pub mod fmt;
pub mod time; pub mod time;
/* Heap memory allocator trait */
#[allow(missing_docs)]
pub mod heap;
// note: does not need to be public // note: does not need to be public
mod char_private; mod char_private;
mod iter_private; mod iter_private;

View file

@ -12,8 +12,9 @@
#![unstable(issue = "32838", feature = "allocator_api")] #![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 alloc_system::System;
pub use core::heap::*;
#[cfg(not(test))] #[cfg(not(test))]
#[doc(hidden)] #[doc(hidden)]