Skip to content

Commit bbaff03

Browse files
committed
Stablize the GlobalAlloc trait
Fixes rust-lang#49668
1 parent 77606f2 commit bbaff03

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: src/libcore/alloc.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ impl From<LayoutErr> for CollectionAllocErr {
467467
/// * `Layout` queries and calculations in general must be correct. Callers of
468468
/// this trait are allowed to rely on the contracts defined on each method,
469469
/// and implementors must ensure such contracts remain true.
470-
#[unstable(feature = "allocator_api", issue = "32838")]
470+
#[stable(feature = "global_alloc", since = "1.28.0")]
471471
pub unsafe trait GlobalAlloc {
472472
/// Allocate memory as described by the given `layout`.
473473
///
@@ -499,6 +499,7 @@ pub unsafe trait GlobalAlloc {
499499
/// Clients wishing to abort computation in response to an
500500
/// allocation error are encouraged to call the [`oom`] function,
501501
/// rather than directly invoking `panic!` or similar.
502+
#[stable(feature = "global_alloc", since = "1.28.0")]
502503
unsafe fn alloc(&self, layout: Layout) -> *mut u8;
503504

504505
/// Deallocate the block of memory at the given `ptr` pointer with the given `layout`.
@@ -513,6 +514,7 @@ pub unsafe trait GlobalAlloc {
513514
///
514515
/// * `layout` must be the same layout that was used
515516
/// to allocated that block of memory,
517+
#[stable(feature = "global_alloc", since = "1.28.0")]
516518
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout);
517519

518520
/// Behaves like `alloc`, but also ensures that the contents
@@ -532,6 +534,7 @@ pub unsafe trait GlobalAlloc {
532534
/// Clients wishing to abort computation in response to an
533535
/// allocation error are encouraged to call the [`oom`] function,
534536
/// rather than directly invoking `panic!` or similar.
537+
#[stable(feature = "global_alloc", since = "1.28.0")]
535538
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
536539
let size = layout.size();
537540
let ptr = self.alloc(layout);
@@ -589,6 +592,7 @@ pub unsafe trait GlobalAlloc {
589592
/// Clients wishing to abort computation in response to a
590593
/// reallocation error are encouraged to call the [`oom`] function,
591594
/// rather than directly invoking `panic!` or similar.
595+
#[stable(feature = "global_alloc", since = "1.28.0")]
592596
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
593597
let new_layout = Layout::from_size_align_unchecked(new_size, layout.align());
594598
let new_ptr = self.alloc(new_layout);

0 commit comments

Comments
 (0)