@@ -112,6 +112,8 @@ impl Layout {
112112 /// The minimum byte alignment for a memory block of this layout.
113113 #[ stable( feature = "alloc_layout" , since = "1.28.0" ) ]
114114 #[ rustc_const_stable( feature = "const_alloc_layout" , since = "1.50.0" ) ]
115+ #[ must_use = "this returns the minimum alignment, \
116+ without modifying the layout"]
115117 #[ inline]
116118 pub const fn align ( & self ) -> usize {
117119 self . align_ . get ( )
@@ -229,6 +231,8 @@ impl Layout {
229231 /// satisfy this constraint is to ensure `align <= self.align()`.
230232 #[ unstable( feature = "alloc_layout_extra" , issue = "55724" ) ]
231233 #[ rustc_const_unstable( feature = "const_alloc_layout" , issue = "67521" ) ]
234+ #[ must_use = "this returns the padding needed, \
235+ without modifying the `Layout`"]
232236 #[ inline]
233237 pub const fn padding_needed_for ( & self , align : usize ) -> usize {
234238 let len = self . size ( ) ;
@@ -262,6 +266,8 @@ impl Layout {
262266 /// This is equivalent to adding the result of `padding_needed_for`
263267 /// to the layout's current size.
264268 #[ stable( feature = "alloc_layout_manipulation" , since = "1.44.0" ) ]
269+ #[ must_use = "this returns a new `Layout`, \
270+ without modifying the original"]
265271 #[ inline]
266272 pub fn pad_to_align ( & self ) -> Layout {
267273 let pad = self . padding_needed_for ( self . align ( ) ) ;
0 commit comments