Skip to content

Commit 763b55a

Browse files
committed
Stabilize alloc::Layout (with only some of its methods)
1 parent 0470325 commit 763b55a

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/libcore/alloc.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn size_align<T>() -> (usize, usize) {
4545
/// requests have positive size. A caller to the `Alloc::alloc`
4646
/// method must either ensure that conditions like this are met, or
4747
/// use specific allocators with looser requirements.)
48-
#[unstable(feature = "allocator_api", issue = "32838")]
48+
#[stable(feature = "alloc_layout", since = "1.28.0")]
4949
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
5050
pub struct Layout {
5151
// size of the requested block of memory, measured in bytes.
@@ -76,7 +76,7 @@ impl Layout {
7676
/// * `size`, when rounded up to the nearest multiple of `align`,
7777
/// must not overflow (i.e. the rounded value must be less than
7878
/// `usize::MAX`).
79-
#[unstable(feature = "allocator_api", issue = "32838")]
79+
#[stable(feature = "alloc_layout", since = "1.28.0")]
8080
#[inline]
8181
pub fn from_size_align(size: usize, align: usize) -> Result<Self, LayoutErr> {
8282
if !align.is_power_of_two() {
@@ -113,24 +113,25 @@ impl Layout {
113113
/// This function is unsafe as it does not verify that `align` is
114114
/// a power-of-two nor `size` aligned to `align` fits within the
115115
/// address space (i.e. the `Layout::from_size_align` preconditions).
116-
#[unstable(feature = "allocator_api", issue = "32838")]
116+
#[stable(feature = "alloc_layout", since = "1.28.0")]
117117
#[inline]
118118
pub unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self {
119119
Layout { size: size, align: align }
120120
}
121121

122122
/// The minimum size in bytes for a memory block of this layout.
123-
#[unstable(feature = "allocator_api", issue = "32838")]
123+
#[stable(feature = "alloc_layout", since = "1.28.0")]
124124
#[inline]
125125
pub fn size(&self) -> usize { self.size }
126126

127127
/// The minimum byte alignment for a memory block of this layout.
128-
#[unstable(feature = "allocator_api", issue = "32838")]
128+
#[stable(feature = "alloc_layout", since = "1.28.0")]
129129
#[inline]
130130
pub fn align(&self) -> usize { self.align }
131131

132132
/// Constructs a `Layout` suitable for holding a value of type `T`.
133-
#[unstable(feature = "allocator_api", issue = "32838")]
133+
#[stable(feature = "alloc_layout", since = "1.28.0")]
134+
#[inline]
134135
pub fn new<T>() -> Self {
135136
let (size, align) = size_align::<T>();
136137
// Note that the align is guaranteed by rustc to be a power of two and
@@ -146,7 +147,8 @@ impl Layout {
146147
/// Produces layout describing a record that could be used to
147148
/// allocate backing structure for `T` (which could be a trait
148149
/// or other unsized type like a slice).
149-
#[unstable(feature = "allocator_api", issue = "32838")]
150+
#[stable(feature = "alloc_layout", since = "1.28.0")]
151+
#[inline]
150152
pub fn for_value<T: ?Sized>(t: &T) -> Self {
151153
let (size, align) = (mem::size_of_val(t), mem::align_of_val(t));
152154
// See rationale in `new` for why this us using an unsafe variant below
@@ -325,14 +327,14 @@ impl Layout {
325327
/// The parameters given to `Layout::from_size_align`
326328
/// or some other `Layout` constructor
327329
/// do not satisfy its documented constraints.
328-
#[unstable(feature = "allocator_api", issue = "32838")]
330+
#[stable(feature = "alloc_layout", since = "1.28.0")]
329331
#[derive(Clone, PartialEq, Eq, Debug)]
330332
pub struct LayoutErr {
331333
private: ()
332334
}
333335

334336
// (we need this for downstream impl of trait Error)
335-
#[unstable(feature = "allocator_api", issue = "32838")]
337+
#[stable(feature = "alloc_layout", since = "1.28.0")]
336338
impl fmt::Display for LayoutErr {
337339
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
338340
f.write_str("invalid parameters to Layout::from_size_align")

0 commit comments

Comments
 (0)