@@ -220,8 +220,9 @@ A type is zero sized (a ZST) if its size is 0. Such types have at most one possi
220220- [ Function items] (see [ type.fn-item.intro] ).
221221- The constructors of [ tuple-like structs] (see [ type.fn-item.intro] ).
222222- The constructors of [ tuple-like enum variants] (see [ type.fn-item.intro] ).
223- - ` repr(C) ` [ structs] with no fields or where all fields are zero-sized (see [ layout.repr.c.struct.size-field-offset] ).
224- - ` repr(transparent) ` [ structs] with no fields or where all fields are zero-sized (see [ layout.repr.transparent.layout-abi] ).
223+ - [ structs] with no fields or where all fields are zero-sized (see [ items.struct.zst] )
224+ - Including those marked with ` repr(C) ` (see [ layout.repr.c.struct.size-field-offset] ).
225+ - or marked with ` repr(transparent) ` (see [ layout.repr.transparent.layout-abi] ).
225226- [ Arrays] of zero-sized types (see [ layout.array] ).
226227- [ Arrays] of length zero (see [ layout.array] ).
227228- [ Unions] of zero-sized types (see [ items.union.common-storage] ).
@@ -231,6 +232,13 @@ A type is zero sized (a ZST) if its size is 0. Such types have at most one possi
231232fn f () {}
232233struct S (u8 );
233234enum E { V (u8 ) }
235+ struct UnitLike ;
236+ struct NoFields {}
237+ struct OnlyZST {
238+ f1 : (),
239+ f2 : [(); 10 ],
240+ f3 : [u8 ; 0 ],
241+ }
234242#[repr(C )]
235243struct C1 {}
236244#[repr(C )]
@@ -257,6 +265,9 @@ assert_eq!(0, size_of::<()>());
257265assert_eq! (0 , size_of_val (& f ));
258266assert_eq! (0 , size_of_val (& S ));
259267assert_eq! (0 , size_of_val (& E :: V ));
268+ assert_eq! (0 , size_of :: <UnitLike >());
269+ assert_eq! (0 , size_of :: <NoFields >());
270+ assert_eq! (0 , size_of :: <OnlyZST >());
260271assert_eq! (0 , size_of :: <C1 >());
261272assert_eq! (0 , size_of :: <C2 >());
262273assert_eq! (0 , size_of :: <T1 >());
0 commit comments