@@ -64,8 +64,9 @@ impl Layout {
6464 /// must not overflow (i.e., the rounded value must be less than
6565 /// `usize::MAX`).
6666 #[ stable( feature = "alloc_layout" , since = "1.28.0" ) ]
67+ #[ rustc_const_unstable( feature = "const_alloc_layout" , issue = "67521" ) ]
6768 #[ 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 > {
6970 if !align. is_power_of_two ( ) {
7071 return Err ( LayoutErr { private : ( ) } ) ;
7172 }
@@ -106,15 +107,17 @@ impl Layout {
106107
107108 /// The minimum size in bytes for a memory block of this layout.
108109 #[ stable( feature = "alloc_layout" , since = "1.28.0" ) ]
110+ #[ rustc_const_unstable( feature = "const_alloc_layout" , issue = "67521" ) ]
109111 #[ inline]
110- pub fn size ( & self ) -> usize {
112+ pub const fn size ( & self ) -> usize {
111113 self . size_
112114 }
113115
114116 /// The minimum byte alignment for a memory block of this layout.
115117 #[ stable( feature = "alloc_layout" , since = "1.28.0" ) ]
118+ #[ rustc_const_unstable( feature = "const_alloc_layout" , issue = "67521" ) ]
116119 #[ inline]
117- pub fn align ( & self ) -> usize {
120+ pub const fn align ( & self ) -> usize {
118121 self . align_ . get ( )
119122 }
120123
@@ -181,8 +184,9 @@ impl Layout {
181184 /// address for the whole allocated block of memory. One way to
182185 /// satisfy this constraint is to ensure `align <= self.align()`.
183186 #[ unstable( feature = "alloc_layout_extra" , issue = "55724" ) ]
187+ #[ rustc_const_unstable( feature = "const_alloc_layout" , issue = "67521" ) ]
184188 #[ inline]
185- pub fn padding_needed_for ( & self , align : usize ) -> usize {
189+ pub const fn padding_needed_for ( & self , align : usize ) -> usize {
186190 let len = self . size ( ) ;
187191
188192 // Rounded up value is:
0 commit comments