@@ -64,8 +64,9 @@ impl Layout {
64
64
/// must not overflow (i.e., the rounded value must be less than
65
65
/// `usize::MAX`).
66
66
#[ stable( feature = "alloc_layout" , since = "1.28.0" ) ]
67
+ #[ rustc_const_unstable( feature = "const_alloc_layout" , issue = "67521" ) ]
67
68
#[ inline]
68
- pub fn from_size_align ( size : usize , align : usize ) -> Result < Self , LayoutErr > {
69
+ pub const fn from_size_align ( size : usize , align : usize ) -> Result < Self , LayoutErr > {
69
70
if !align. is_power_of_two ( ) {
70
71
return Err ( LayoutErr { private : ( ) } ) ;
71
72
}
@@ -106,15 +107,17 @@ impl Layout {
106
107
107
108
/// The minimum size in bytes for a memory block of this layout.
108
109
#[ stable( feature = "alloc_layout" , since = "1.28.0" ) ]
110
+ #[ rustc_const_unstable( feature = "const_alloc_layout" , issue = "67521" ) ]
109
111
#[ inline]
110
- pub fn size ( & self ) -> usize {
112
+ pub const fn size ( & self ) -> usize {
111
113
self . size_
112
114
}
113
115
114
116
/// The minimum byte alignment for a memory block of this layout.
115
117
#[ stable( feature = "alloc_layout" , since = "1.28.0" ) ]
118
+ #[ rustc_const_unstable( feature = "const_alloc_layout" , issue = "67521" ) ]
116
119
#[ inline]
117
- pub fn align ( & self ) -> usize {
120
+ pub const fn align ( & self ) -> usize {
118
121
self . align_ . get ( )
119
122
}
120
123
@@ -181,8 +184,9 @@ impl Layout {
181
184
/// address for the whole allocated block of memory. One way to
182
185
/// satisfy this constraint is to ensure `align <= self.align()`.
183
186
#[ unstable( feature = "alloc_layout_extra" , issue = "55724" ) ]
187
+ #[ rustc_const_unstable( feature = "const_alloc_layout" , issue = "67521" ) ]
184
188
#[ inline]
185
- pub fn padding_needed_for ( & self , align : usize ) -> usize {
189
+ pub const fn padding_needed_for ( & self , align : usize ) -> usize {
186
190
let len = self . size ( ) ;
187
191
188
192
// Rounded up value is:
0 commit comments