Skip to content

Commit

Permalink
Documented the #[repr(align(x))] attribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitshifter committed Dec 26, 2017
1 parent 36fc52c commit 8e76a8b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,14 @@ On `enum`s:
On `struct`s:

- `repr` - specifies the representation to use for this struct. Takes a list
of options. The currently accepted ones are `C` and `packed`, which may be
combined. `C` will use a C ABI compatible struct layout, and `packed` will
remove any padding between fields (note that this is very fragile and may
break platforms which require aligned access).
of options. The currently accepted ones are `C`, `align` and `packed`.
`C` will use a C ABI compatible struct layout. `C` can be used in conjunction
with `align` or `packed`. `#[repr(align(x))]` takes one argument which
increases alignment of the `struct` to the given value. The alignment must be
an unsigned power of two. `packed` will remove any padding between
fields (note that this is very fragile and may break platforms which require
aligned access). `align` and `packed` cannot be applied on the same struct,
and a `packed` struct cannot transitively contain another struct with `align`.

On `union`s:

Expand Down Expand Up @@ -416,4 +420,4 @@ You can implement `derive` for your own type through [procedural macros].

[Doc comments]: comments.html#doc-comments
[The Rustdoc Book]: ../rustdoc/the-doc-attribute.html
[procedural macros]: procedural-macros.html
[procedural macros]: procedural-macros.html

0 comments on commit 8e76a8b

Please sign in to comment.