about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2020-11-22 23:00:56 +0100
committerGitHub <noreply@github.com>2020-11-22 23:00:56 +0100
commit186ec64947a0207fef811bfefb19453068e3d87d (patch)
tree1303c42a48d9e4b786c28d153c096dfb428c64a5
parent4407049fcbdc8fce56573a4271b90384a269abbc (diff)
parent9050d12714e65ed135833b9dfd1b9619c6188ca4 (diff)
downloadrust-186ec64947a0207fef811bfefb19453068e3d87d.tar.gz
rust-186ec64947a0207fef811bfefb19453068e3d87d.zip
Rollup merge of #78305 - ChrisDenton:const-layout, r=oli-obk
Stabilize alloc::Layout const functions

Stabilizes #67521. In particular the following stable methods are stabilized as `const fn`:

* `size`
* `align`
* `from_size_align`

Stabilizing `size` and `align` should not be controversial as they are simple (usize and NonZeroUsize) fields and I don't think there's any reason to make them not const compatible in the future. That being true, the other methods are trivially `const`. The only other issue being returning a `Result` from a `const fn` but this has been made more usable by recent stabilizations.
-rw-r--r--library/core/src/alloc/layout.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/library/core/src/alloc/layout.rs b/library/core/src/alloc/layout.rs
index 2258d9614d5..339d85902b8 100644
--- a/library/core/src/alloc/layout.rs
+++ b/library/core/src/alloc/layout.rs
@@ -50,7 +50,7 @@ impl Layout {
     ///    must not overflow (i.e., the rounded value must be less than
     ///    or equal to `usize::MAX`).
     #[stable(feature = "alloc_layout", since = "1.28.0")]
-    #[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
+    #[rustc_const_stable(feature = "const_alloc_layout", since = "1.50.0")]
     #[inline]
     pub const fn from_size_align(size: usize, align: usize) -> Result<Self, LayoutError> {
         if !align.is_power_of_two() {
@@ -96,7 +96,7 @@ impl Layout {
 
     /// The minimum size in bytes for a memory block of this layout.
     #[stable(feature = "alloc_layout", since = "1.28.0")]
-    #[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
+    #[rustc_const_stable(feature = "const_alloc_layout", since = "1.50.0")]
     #[inline]
     pub const fn size(&self) -> usize {
         self.size_
@@ -104,7 +104,7 @@ impl Layout {
 
     /// The minimum byte alignment for a memory block of this layout.
     #[stable(feature = "alloc_layout", since = "1.28.0")]
-    #[rustc_const_unstable(feature = "const_alloc_layout", issue = "67521")]
+    #[rustc_const_stable(feature = "const_alloc_layout", since = "1.50.0")]
     #[inline]
     pub const fn align(&self) -> usize {
         self.align_.get()