@@ -1221,6 +1221,9 @@ struct Cookie;
1221
1221
let c = [Cookie, Cookie, Cookie, Cookie];
1222
1222
~~~~
1223
1223
1224
+ The precise memory layout of a structure is not specified. One can specify a
1225
+ particular layout using the [ ` repr ` attribute] (
1226
+
1224
1227
By using the ` struct_inherit ` feature gate, structures may use single inheritance. A Structure may only
1225
1228
inherit from a single other structure, called the _ super-struct_ . The inheriting structure (sub-struct)
1226
1229
acts as if all fields in the super-struct were present in the sub-struct. Fields declared in a sub-struct
@@ -1851,6 +1854,23 @@ interpreted:
1851
1854
- ` linkage ` - on a static, this specifies the [ linkage
1852
1855
type] ( http://llvm.org/docs/LangRef.html#linkage-types ) .
1853
1856
1857
+ On ` enum ` s:
1858
+
1859
+ - ` repr ` - on C-like enums, this sets the underlying type used for
1860
+ representation. Takes one argument, which is the primitive
1861
+ type this enum should be represented for, or ` C ` , which specifies that it
1862
+ should be the default ` enum ` size of the C ABI for that platform. Note that
1863
+ enum representation in C is undefined, and this may be incorrect when the C
1864
+ code is compiled with certain flags.
1865
+
1866
+ On ` struct ` s:
1867
+
1868
+ - ` repr ` - specifies the representation to use for this struct. Takes a list
1869
+ of options. The currently accepted ones are ` C ` and ` packed ` , which may be
1870
+ combined. ` C ` will use a C ABI comptible struct layout, and ` packed ` will
1871
+ remove any padding between fields (note that this is very fragile and may
1872
+ break platforms which require aligned access).
1873
+
1854
1874
### Miscellaneous attributes
1855
1875
1856
1876
- ` link_section ` - on statics and functions, this specifies the section of the
@@ -1860,12 +1880,6 @@ interpreted:
1860
1880
symbol for this item to its identifier.
1861
1881
- ` packed ` - on structs or enums, eliminate any padding that would be used to
1862
1882
align fields.
1863
- - ` repr ` - on C-like enums, this sets the underlying type used for
1864
- representation. Useful for FFI. Takes one argument, which is the primitive
1865
- type this enum should be represented for, or ` C ` , which specifies that it
1866
- should be the default ` enum ` size of the C ABI for that platform. Note that
1867
- enum representation in C is undefined, and this may be incorrect when the C
1868
- code is compiled with certain flags.
1869
1883
- ` simd ` - on certain tuple structs, derive the arithmetic operators, which
1870
1884
lower to the target's SIMD instructions, if any.
1871
1885
- ` static_assert ` - on statics whose type is ` bool ` , terminates compilation
0 commit comments