about summary refs log tree commit diff
path: root/src/libcore/alloc.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-01-09 19:21:58 +0000
committerbors <bors@rust-lang.org>2020-01-09 19:21:58 +0000
commit72b2bd55edbb1e63a930c5ddd08b25e4f9044786 (patch)
treece6695b7a17f751eb6c469151be83373687c6952 /src/libcore/alloc.rs
parent59eb49d0da83fff01ae3c63f2e282b953e5f88df (diff)
parent9e83df0f69d0509c411808766c3472f11476bd9e (diff)
downloadrust-72b2bd55edbb1e63a930c5ddd08b25e4f9044786.tar.gz
rust-72b2bd55edbb1e63a930c5ddd08b25e4f9044786.zip
Auto merge of #68067 - JohnTitor:rollup-vsj5won, r=JohnTitor
Rollup of 10 pull requests

Successful merges:

 - #66254 (Make Layout::new const)
 - #67122 (Do not deduplicate diagnostics in UI tests)
 - #67358 (Add HashSet::get_or_insert_owned)
 - #67725 (Simplify into_key_slice_mut)
 - #67935 (Relax the Sized bounds on Pin::map_unchecked(_mut))
 - #67967 (Delay bug to prevent ICE in MIR borrowck)
 - #67975 (Export public scalar statics in wasm)
 - #68006 (Recognise riscv64 in compiletest)
 - #68040 (Cleanup)
 - #68054 (doc: add Null-unchecked version section to mut pointer as_mut method)

Failed merges:

 - #67258 (Introduce `X..`, `..X`, and `..=X` range patterns)

r? @ghost
Diffstat (limited to 'src/libcore/alloc.rs')
-rw-r--r--src/libcore/alloc.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs
index b2d4b1b5fb9..163f9170b8b 100644
--- a/src/libcore/alloc.rs
+++ b/src/libcore/alloc.rs
@@ -17,7 +17,7 @@ use crate::usize;
 #[derive(Debug)]
 pub struct Excess(pub NonNull<u8>, pub usize);
 
-fn size_align<T>() -> (usize, usize) {
+const fn size_align<T>() -> (usize, usize) {
     (mem::size_of::<T>(), mem::align_of::<T>())
 }
 
@@ -120,14 +120,14 @@ impl Layout {
 
     /// Constructs a `Layout` suitable for holding a value of type `T`.
     #[stable(feature = "alloc_layout", since = "1.28.0")]
+    #[rustc_const_stable(feature = "alloc_layout_const_new", since = "1.42.0")]
     #[inline]
-    pub fn new<T>() -> Self {
+    pub const fn new<T>() -> Self {
         let (size, align) = size_align::<T>();
         // Note that the align is guaranteed by rustc to be a power of two and
         // the size+align combo is guaranteed to fit in our address space. As a
         // result use the unchecked constructor here to avoid inserting code
         // that panics if it isn't optimized well enough.
-        debug_assert!(Layout::from_size_align(size, align).is_ok());
         unsafe { Layout::from_size_align_unchecked(size, align) }
     }