]> git.lizzy.rs Git - rust.git/commitdiff
Stabilize alloc::Layout (with only some of its methods)
authorSimon Sapin <simon.sapin@exyr.org>
Thu, 31 May 2018 17:10:08 +0000 (19:10 +0200)
committerSimon Sapin <simon.sapin@exyr.org>
Mon, 11 Jun 2018 20:48:33 +0000 (13:48 -0700)
src/libcore/alloc.rs

index 97ad55304be79ceaeaba8dc21ac66a91b56e2686..a65a06d0c8933d7507b8318c0f081b21af904411 100644 (file)
@@ -46,7 +46,7 @@ fn size_align<T>() -> (usize, usize) {
 /// requests have positive size. A caller to the `Alloc::alloc`
 /// method must either ensure that conditions like this are met, or
 /// use specific allocators with looser requirements.)
-#[unstable(feature = "allocator_api", issue = "32838")]
+#[stable(feature = "alloc_layout", since = "1.28.0")]
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
 pub struct Layout {
     // size of the requested block of memory, measured in bytes.
@@ -72,7 +72,7 @@ impl Layout {
     /// * `size`, when rounded up to the nearest multiple of `align`,
     ///    must not overflow (i.e. the rounded value must be less than
     ///    `usize::MAX`).
-    #[unstable(feature = "allocator_api", issue = "32838")]
+    #[stable(feature = "alloc_layout", since = "1.28.0")]
     #[inline]
     pub fn from_size_align(size: usize, align: usize) -> Result<Self, LayoutErr> {
         if !align.is_power_of_two() {
@@ -108,24 +108,24 @@ pub fn from_size_align(size: usize, align: usize) -> Result<Self, LayoutErr> {
     ///
     /// This function is unsafe as it does not verify the preconditions from
     /// [`Layout::from_size_align`](#method.from_size_align).
-    #[unstable(feature = "allocator_api", issue = "32838")]
+    #[stable(feature = "alloc_layout", since = "1.28.0")]
     #[inline]
     pub unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self {
         Layout { size_: size, align_: NonZeroUsize::new_unchecked(align) }
     }
 
     /// The minimum size in bytes for a memory block of this layout.
-    #[unstable(feature = "allocator_api", issue = "32838")]
+    #[stable(feature = "alloc_layout", since = "1.28.0")]
     #[inline]
     pub fn size(&self) -> usize { self.size_ }
 
     /// The minimum byte alignment for a memory block of this layout.
-    #[unstable(feature = "allocator_api", issue = "32838")]
+    #[stable(feature = "alloc_layout", since = "1.28.0")]
     #[inline]
     pub fn align(&self) -> usize { self.align_.get() }
 
     /// Constructs a `Layout` suitable for holding a value of type `T`.
-    #[unstable(feature = "allocator_api", issue = "32838")]
+    #[stable(feature = "alloc_layout", since = "1.28.0")]
     #[inline]
     pub fn new<T>() -> Self {
         let (size, align) = size_align::<T>();
@@ -142,7 +142,7 @@ pub fn new<T>() -> Self {
     /// Produces layout describing a record that could be used to
     /// allocate backing structure for `T` (which could be a trait
     /// or other unsized type like a slice).
-    #[unstable(feature = "allocator_api", issue = "32838")]
+    #[stable(feature = "alloc_layout", since = "1.28.0")]
     #[inline]
     pub fn for_value<T: ?Sized>(t: &T) -> Self {
         let (size, align) = (mem::size_of_val(t), mem::align_of_val(t));
@@ -331,14 +331,14 @@ pub fn array<T>(n: usize) -> Result<Self, LayoutErr> {
 /// The parameters given to `Layout::from_size_align`
 /// or some other `Layout` constructor
 /// do not satisfy its documented constraints.
-#[unstable(feature = "allocator_api", issue = "32838")]
+#[stable(feature = "alloc_layout", since = "1.28.0")]
 #[derive(Clone, PartialEq, Eq, Debug)]
 pub struct LayoutErr {
     private: ()
 }
 
 // (we need this for downstream impl of trait Error)
-#[unstable(feature = "allocator_api", issue = "32838")]
+#[stable(feature = "alloc_layout", since = "1.28.0")]
 impl fmt::Display for LayoutErr {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         f.write_str("invalid parameters to Layout::from_size_align")