@@ -60,7 +60,7 @@ impl Layout {
6060 #[ inline]
6161 pub const fn from_size_align ( size : usize , align : usize ) -> Result < Self , LayoutError > {
6262 if !align. is_power_of_two ( ) {
63- return Err ( LayoutError { private : ( ) } ) ;
63+ return Err ( LayoutError ) ;
6464 }
6565
6666 // (power-of-two implies align != 0.)
@@ -78,7 +78,7 @@ impl Layout {
7878 // Above implies that checking for summation overflow is both
7979 // necessary and sufficient.
8080 if size > usize:: MAX - ( align - 1 ) {
81- return Err ( LayoutError { private : ( ) } ) ;
81+ return Err ( LayoutError ) ;
8282 }
8383
8484 // SAFETY: the conditions for `from_size_align_unchecked` have been
@@ -288,7 +288,7 @@ impl Layout {
288288 // > must not overflow (i.e., the rounded value must be less than
289289 // > `usize::MAX`)
290290 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 ) ?;
292292
293293 // SAFETY: self.align is already known to be valid and alloc_size has been
294294 // padded already.
@@ -346,8 +346,8 @@ impl Layout {
346346 let new_align = cmp:: max ( self . align ( ) , next. align ( ) ) ;
347347 let pad = self . padding_needed_for ( next. align ( ) ) ;
348348
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 ) ?;
351351
352352 let layout = Layout :: from_size_align ( new_size, new_align) ?;
353353 Ok ( ( layout, offset) )
@@ -368,7 +368,7 @@ impl Layout {
368368 #[ unstable( feature = "alloc_layout_extra" , issue = "55724" ) ]
369369 #[ inline]
370370 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 ) ?;
372372 Layout :: from_size_align ( size, self . align ( ) )
373373 }
374374
@@ -381,7 +381,7 @@ impl Layout {
381381 #[ unstable( feature = "alloc_layout_extra" , issue = "55724" ) ]
382382 #[ inline]
383383 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 ) ?;
385385 Layout :: from_size_align ( new_size, self . align ( ) )
386386 }
387387
@@ -409,10 +409,9 @@ pub type LayoutErr = LayoutError;
409409/// or some other `Layout` constructor
410410/// do not satisfy its documented constraints.
411411#[ stable( feature = "alloc_layout_error" , since = "1.50.0" ) ]
412+ #[ non_exhaustive]
412413#[ derive( Clone , PartialEq , Eq , Debug ) ]
413- pub struct LayoutError {
414- private : ( ) ,
415- }
414+ pub struct LayoutError ;
416415
417416// (we need this for downstream impl of trait Error)
418417#[ stable( feature = "alloc_layout" , since = "1.28.0" ) ]
0 commit comments