Skip to content

Commit 94d1970

Browse files
committed
Move the alloc::allocator module to core::heap
This is the `Alloc` trait and its dependencies.
1 parent 1169541 commit 94d1970

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

src/liballoc/heap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use core::intrinsics::{min_align_of_val, size_of_val};
1919
use core::mem::{self, ManuallyDrop};
2020
use core::usize;
2121

22-
pub use allocator::*;
22+
pub use core::heap::*;
2323
#[doc(hidden)]
2424
pub mod __core {
2525
pub use core::*;

src/liballoc/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
#![cfg_attr(not(test), feature(exact_size_is_empty))]
8282
#![cfg_attr(not(test), feature(generator_trait))]
8383
#![cfg_attr(test, feature(rand, test))]
84+
#![feature(allocator_api)]
8485
#![feature(allow_internal_unstable)]
8586
#![feature(ascii_ctype)]
8687
#![feature(box_into_raw_non_null)]
@@ -145,9 +146,9 @@ extern crate std_unicode;
145146
#[macro_use]
146147
mod macros;
147148

148-
// Allocator trait and helper struct definitions
149-
150-
pub mod allocator;
149+
#[rustc_deprecated(since = "1.27.0", reason = "use the heap module in core, alloc, or std instead")]
150+
#[unstable(feature = "allocator_api", issue = "32838")]
151+
pub use core::heap as allocator;
151152

152153
// Heaps provided for low-level allocation strategies
153154

src/liballoc/allocator.rs renamed to src/libcore/heap.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
tracing garbage collector",
1616
issue = "32838")]
1717

18-
use core::cmp;
19-
use core::fmt;
20-
use core::mem;
21-
use core::usize;
22-
use core::ptr::{self, NonNull};
18+
use cmp;
19+
use fmt;
20+
use mem;
21+
use usize;
22+
use ptr::{self, NonNull};
2323

2424
/// Represents the combination of a starting address and
2525
/// a total capacity of the returned block.
@@ -568,7 +568,7 @@ pub unsafe trait Alloc {
568568
/// invoked method, and let the client decide whether to invoke
569569
/// this `oom` method in response.
570570
fn oom(&mut self, _: AllocErr) -> ! {
571-
unsafe { ::core::intrinsics::abort() }
571+
unsafe { ::intrinsics::abort() }
572572
}
573573

574574
// == ALLOCATOR-SPECIFIC QUANTITIES AND LIMITS ==

src/libcore/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ pub mod hash;
185185
pub mod fmt;
186186
pub mod time;
187187

188+
/* Heap memory allocator trait */
189+
#[allow(missing_docs)]
190+
pub mod heap;
191+
188192
// note: does not need to be public
189193
mod char_private;
190194
mod iter_private;

src/libstd/heap.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
1313
#![unstable(issue = "32838", feature = "allocator_api")]
1414

15-
pub use alloc::heap::{Heap, Alloc, Layout, Excess, CannotReallocInPlace, AllocErr};
15+
pub use alloc::heap::Heap;
1616
pub use alloc_system::System;
17+
pub use core::heap::*;
1718

1819
#[cfg(not(test))]
1920
#[doc(hidden)]

0 commit comments

Comments
 (0)