From bbaff036e7acef9f5b6bfdcb6339bfc6fa7ecfcf Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 31 May 2018 19:13:18 +0200 Subject: Stablize the GlobalAlloc trait Fixes https://github.com/rust-lang/rust/issues/49668 --- src/libcore/alloc.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs index a65a06d0c89..9c324cdb4ed 100644 --- a/src/libcore/alloc.rs +++ b/src/libcore/alloc.rs @@ -467,7 +467,7 @@ impl From for CollectionAllocErr { /// * `Layout` queries and calculations in general must be correct. Callers of /// this trait are allowed to rely on the contracts defined on each method, /// and implementors must ensure such contracts remain true. -#[unstable(feature = "allocator_api", issue = "32838")] +#[stable(feature = "global_alloc", since = "1.28.0")] pub unsafe trait GlobalAlloc { /// Allocate memory as described by the given `layout`. /// @@ -499,6 +499,7 @@ pub unsafe trait GlobalAlloc { /// Clients wishing to abort computation in response to an /// allocation error are encouraged to call the [`oom`] function, /// rather than directly invoking `panic!` or similar. + #[stable(feature = "global_alloc", since = "1.28.0")] unsafe fn alloc(&self, layout: Layout) -> *mut u8; /// Deallocate the block of memory at the given `ptr` pointer with the given `layout`. @@ -513,6 +514,7 @@ pub unsafe trait GlobalAlloc { /// /// * `layout` must be the same layout that was used /// to allocated that block of memory, + #[stable(feature = "global_alloc", since = "1.28.0")] unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout); /// Behaves like `alloc`, but also ensures that the contents @@ -532,6 +534,7 @@ pub unsafe trait GlobalAlloc { /// Clients wishing to abort computation in response to an /// allocation error are encouraged to call the [`oom`] function, /// rather than directly invoking `panic!` or similar. + #[stable(feature = "global_alloc", since = "1.28.0")] unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { let size = layout.size(); let ptr = self.alloc(layout); @@ -589,6 +592,7 @@ pub unsafe trait GlobalAlloc { /// Clients wishing to abort computation in response to a /// reallocation error are encouraged to call the [`oom`] function, /// rather than directly invoking `panic!` or similar. + #[stable(feature = "global_alloc", since = "1.28.0")] unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { let new_layout = Layout::from_size_align_unchecked(new_size, layout.align()); let new_ptr = self.alloc(new_layout); -- cgit 1.4.1-3-g733a5