@@ -60,7 +60,7 @@ impl Layout {
60
60
#[ inline]
61
61
pub const fn from_size_align ( size : usize , align : usize ) -> Result < Self , LayoutError > {
62
62
if !align. is_power_of_two ( ) {
63
- return Err ( LayoutError { private : ( ) } ) ;
63
+ return Err ( LayoutError ) ;
64
64
}
65
65
66
66
// (power-of-two implies align != 0.)
@@ -78,7 +78,7 @@ impl Layout {
78
78
// Above implies that checking for summation overflow is both
79
79
// necessary and sufficient.
80
80
if size > usize:: MAX - ( align - 1 ) {
81
- return Err ( LayoutError { private : ( ) } ) ;
81
+ return Err ( LayoutError ) ;
82
82
}
83
83
84
84
// SAFETY: the conditions for `from_size_align_unchecked` have been
@@ -288,7 +288,7 @@ impl Layout {
288
288
// > must not overflow (i.e., the rounded value must be less than
289
289
// > `usize::MAX`)
290
290
let padded_size = self . size ( ) + self . padding_needed_for ( self . align ( ) ) ;
291
- let alloc_size = padded_size. checked_mul ( n) . ok_or ( LayoutError { private : ( ) } ) ?;
291
+ let alloc_size = padded_size. checked_mul ( n) . ok_or ( LayoutError ) ?;
292
292
293
293
// SAFETY: self.align is already known to be valid and alloc_size has been
294
294
// padded already.
@@ -346,8 +346,8 @@ impl Layout {
346
346
let new_align = cmp:: max ( self . align ( ) , next. align ( ) ) ;
347
347
let pad = self . padding_needed_for ( next. align ( ) ) ;
348
348
349
- let offset = self . size ( ) . checked_add ( pad) . ok_or ( LayoutError { private : ( ) } ) ?;
350
- let new_size = offset. checked_add ( next. size ( ) ) . ok_or ( LayoutError { private : ( ) } ) ?;
349
+ let offset = self . size ( ) . checked_add ( pad) . ok_or ( LayoutError ) ?;
350
+ let new_size = offset. checked_add ( next. size ( ) ) . ok_or ( LayoutError ) ?;
351
351
352
352
let layout = Layout :: from_size_align ( new_size, new_align) ?;
353
353
Ok ( ( layout, offset) )
@@ -368,7 +368,7 @@ impl Layout {
368
368
#[ unstable( feature = "alloc_layout_extra" , issue = "55724" ) ]
369
369
#[ inline]
370
370
pub fn repeat_packed ( & self , n : usize ) -> Result < Self , LayoutError > {
371
- let size = self . size ( ) . checked_mul ( n) . ok_or ( LayoutError { private : ( ) } ) ?;
371
+ let size = self . size ( ) . checked_mul ( n) . ok_or ( LayoutError ) ?;
372
372
Layout :: from_size_align ( size, self . align ( ) )
373
373
}
374
374
@@ -381,7 +381,7 @@ impl Layout {
381
381
#[ unstable( feature = "alloc_layout_extra" , issue = "55724" ) ]
382
382
#[ inline]
383
383
pub fn extend_packed ( & self , next : Self ) -> Result < Self , LayoutError > {
384
- let new_size = self . size ( ) . checked_add ( next. size ( ) ) . ok_or ( LayoutError { private : ( ) } ) ?;
384
+ let new_size = self . size ( ) . checked_add ( next. size ( ) ) . ok_or ( LayoutError ) ?;
385
385
Layout :: from_size_align ( new_size, self . align ( ) )
386
386
}
387
387
@@ -409,10 +409,9 @@ pub type LayoutErr = LayoutError;
409
409
/// or some other `Layout` constructor
410
410
/// do not satisfy its documented constraints.
411
411
#[ stable( feature = "alloc_layout_error" , since = "1.50.0" ) ]
412
+ #[ non_exhaustive]
412
413
#[ derive( Clone , PartialEq , Eq , Debug ) ]
413
- pub struct LayoutError {
414
- private : ( ) ,
415
- }
414
+ pub struct LayoutError ;
416
415
417
416
// (we need this for downstream impl of trait Error)
418
417
#[ stable( feature = "alloc_layout" , since = "1.28.0" ) ]
0 commit comments