@@ -112,6 +112,8 @@ impl Layout {
112
112
/// The minimum byte alignment for a memory block of this layout.
113
113
#[ stable( feature = "alloc_layout" , since = "1.28.0" ) ]
114
114
#[ rustc_const_stable( feature = "const_alloc_layout" , since = "1.50.0" ) ]
115
+ #[ must_use = "this returns the minimum alignment, \
116
+ without modifying the layout"]
115
117
#[ inline]
116
118
pub const fn align ( & self ) -> usize {
117
119
self . align_ . get ( )
@@ -229,6 +231,8 @@ impl Layout {
229
231
/// satisfy this constraint is to ensure `align <= self.align()`.
230
232
#[ unstable( feature = "alloc_layout_extra" , issue = "55724" ) ]
231
233
#[ rustc_const_unstable( feature = "const_alloc_layout" , issue = "67521" ) ]
234
+ #[ must_use = "this returns the padding needed, \
235
+ without modifying the `Layout`"]
232
236
#[ inline]
233
237
pub const fn padding_needed_for ( & self , align : usize ) -> usize {
234
238
let len = self . size ( ) ;
@@ -262,6 +266,8 @@ impl Layout {
262
266
/// This is equivalent to adding the result of `padding_needed_for`
263
267
/// to the layout's current size.
264
268
#[ stable( feature = "alloc_layout_manipulation" , since = "1.44.0" ) ]
269
+ #[ must_use = "this returns a new `Layout`, \
270
+ without modifying the original"]
265
271
#[ inline]
266
272
pub fn pad_to_align ( & self ) -> Layout {
267
273
let pad = self . padding_needed_for ( self . align ( ) ) ;
0 commit comments