Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/liballoc/heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
7 changes: 4 additions & 3 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions src/liballoc/allocator.rs → src/libcore/heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 ==
Expand Down
4 changes: 4 additions & 0 deletions src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/libstd/heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down