Skip to content

Commit 83b88f8

Browse files
committed
Stablize the GlobalAlloc trait
Fixes rust-lang#49668
1 parent 763b55a commit 83b88f8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/libcore/alloc.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ impl From<AllocErr> for CollectionAllocErr {
455455
/// * `Layout` queries and calculations in general must be correct. Callers of
456456
/// this trait are allowed to rely on the contracts defined on each method,
457457
/// and implementors must ensure such contracts remain true.
458-
#[unstable(feature = "allocator_api", issue = "32838")]
458+
#[stable(feature = "global_alloc", since = "1.28.0")]
459459
pub unsafe trait GlobalAlloc {
460460
/// Allocate memory as described by the given `layout`.
461461
///
@@ -487,6 +487,7 @@ pub unsafe trait GlobalAlloc {
487487
/// Clients wishing to abort computation in response to an
488488
/// allocation error are encouraged to call the [`oom`] function,
489489
/// rather than directly invoking `panic!` or similar.
490+
#[stable(feature = "global_alloc", since = "1.28.0")]
490491
unsafe fn alloc(&self, layout: Layout) -> *mut u8;
491492

492493
/// Deallocate the block of memory at the given `ptr` pointer with the given `layout`.
@@ -501,6 +502,7 @@ pub unsafe trait GlobalAlloc {
501502
///
502503
/// * `layout` must be the same layout that was used
503504
/// to allocated that block of memory,
505+
#[stable(feature = "global_alloc", since = "1.28.0")]
504506
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout);
505507

506508
/// Behaves like `alloc`, but also ensures that the contents
@@ -520,6 +522,7 @@ pub unsafe trait GlobalAlloc {
520522
/// Clients wishing to abort computation in response to an
521523
/// allocation error are encouraged to call the [`oom`] function,
522524
/// rather than directly invoking `panic!` or similar.
525+
#[stable(feature = "global_alloc", since = "1.28.0")]
523526
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
524527
let size = layout.size();
525528
let ptr = self.alloc(layout);
@@ -577,6 +580,7 @@ pub unsafe trait GlobalAlloc {
577580
/// Clients wishing to abort computation in response to a
578581
/// reallocation error are encouraged to call the [`oom`] function,
579582
/// rather than directly invoking `panic!` or similar.
583+
#[stable(feature = "global_alloc", since = "1.28.0")]
580584
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
581585
let new_layout = Layout::from_size_align_unchecked(new_size, layout.align());
582586
let new_ptr = self.alloc(new_layout);

0 commit comments

Comments
 (0)