Skip to content

Commit 086cecb

Browse files
committed
Inline and remove layout::size_align.
1 parent 1454bbd commit 086cecb

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

library/core/src/alloc/layout.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ use crate::mem;
44
use crate::num::NonZeroUsize;
55
use crate::ptr::NonNull;
66

7-
const fn size_align<T>() -> (usize, usize) {
8-
(mem::size_of::<T>(), mem::align_of::<T>())
9-
}
10-
117
/// Layout of a block of memory.
128
///
139
/// An instance of `Layout` describes a particular layout of memory.
@@ -115,12 +111,11 @@ impl Layout {
115111
#[rustc_const_stable(feature = "alloc_layout_const_new", since = "1.42.0")]
116112
#[inline]
117113
pub const fn new<T>() -> Self {
118-
let (size, align) = size_align::<T>();
119114
// SAFETY: the align is guaranteed by Rust to be a power of two and
120115
// the size+align combo is guaranteed to fit in our address space. As a
121116
// result use the unchecked constructor here to avoid inserting code
122117
// that panics if it isn't optimized well enough.
123-
unsafe { Layout::from_size_align_unchecked(size, align) }
118+
unsafe { Layout::from_size_align_unchecked(mem::size_of::<T>(), mem::align_of::<T>()) }
124119
}
125120

126121
/// Produces layout describing a record that could be used to

0 commit comments

Comments
 (0)