@@ -357,13 +357,14 @@ Like all ways to create undefined behavior in safe Rust, this is a bug.
357
357
358
358
### The ` transparent ` Representation
359
359
360
- The ` transparent ` representation can only be used on ` struct ` s that have:
360
+ The ` transparent ` representation can only be used on a [ ` struct ` ] [ structs ]
361
+ or an [ ` enum ` ] [ enumerations ] with a single variant that has:
361
362
362
363
- a single field with non-zero size, and
363
364
- any number of fields with size 0 and alignment 1 (e.g. [ ` PhantomData<T> ` ] ).
364
365
365
- Structs with this representation have the same layout and ABI as the single
366
- non-zero sized field.
366
+ Structs and enums with this representation have the same layout and ABI
367
+ as the single non-zero sized field.
367
368
368
369
This is different than the ` C ` representation because
369
370
a struct with the ` C ` representation will always have the ABI of a ` C ` ` struct `
@@ -380,12 +381,14 @@ used with any other representation.
380
381
[ `Sized` ] : ../std/marker/trait.Sized.html
381
382
[ dynamically sized types ] : dynamically-sized-types.md
382
383
[ C-like enumerations ] : items/enumerations.md#custom-discriminant-values-for-fieldless-enumerations
384
+ [ enumerations ] : items/enumerations.md
383
385
[ zero-variant enumerations ] : items/enumerations.md#zero-variant-enums
384
386
[ undefined behavior ] : behavior-considered-undefined.md
385
387
[ 27060 ] : https://github.com/rust-lang/rust/issues/27060
386
388
[ `PhantomData<T>` ] : special-types-and-traits.md#phantomdatat
387
389
[ Default ] : #the-default-representation
388
390
[ `C` ] : #the-c-representation
389
391
[ primitive representations ] : #primitive-representations
392
+ [ structs ] : items/structs.md
390
393
[ `transparent` ] : #the-transparent-representation
391
394
[ `Layout` ] : ../std/alloc/struct.Layout.html
0 commit comments