Conversation
Centril
left a comment
There was a problem hiding this comment.
My overall sense is that the text added here would be more succinctly described in a few equations, but I think this is mostly good for now.
src/type-layout.md
Outdated
| It modifies the representation (either the default or `C`) by removing any | ||
| padding bytes and forcing the alignment of the type to `1`. | ||
| The `packed` representation sets the alignment to the smaller of the specified | ||
| packing and the current alignment (either default or `C`). The alignments of |
There was a problem hiding this comment.
Here the "default" alignment is referenced but above "primitive alignment" is used... we should pick one phrasing.
There was a problem hiding this comment.
Get rid of both "current' and "primitive". Get rid of the parenthetical. Instead spell it out explicitly that if the type has the default or C representation, and the alignment from that representation is smaller, it will use that alignment.
src/type-layout.md
Outdated
| It modifies the representation (either the default or `C`) by removing any | ||
| padding bytes and forcing the alignment of the type to `1`. | ||
| The `packed` representation sets the alignment to the smaller of the specified | ||
| packing and the current alignment (either default or `C`). The alignments of |
There was a problem hiding this comment.
"or C" is not super clear wrt. referring to C-the-language
Co-Authored-By: ehuss <eric@huss.org>
|
I added an experimental commit to propose a different way of documenting these I do have some concerns and doubts:
|
src/type-layout.md
Outdated
| The possible representations for a type are the default representation, `C`, | ||
| the primitive representations, `packed`, and `transparent`. Multiple | ||
| representations can be applied to a single type. | ||
| the primitive representations, and `transparent`. |
There was a problem hiding this comment.
Itemize ^
Also make it clear what the "primitive representations" entail (by itemizing all the primitive reprs)
src/type-layout.md
Outdated
| `#[repr(align(x))]`. The alignment value must be a power of two from 1 up to | ||
| 2<sup>29</sup>. | ||
|
|
||
| The `align` modifier raises the type's alignment to the specified alignment. |
There was a problem hiding this comment.
This is a partial repetition of what you said in the leading paragraph.
src/type-layout.md
Outdated
| 2<sup>29</sup>. | ||
|
|
||
| The `align` modifier raises the type's alignment to the specified alignment. | ||
| If the specified alignment is less than the alignment of the type without the |
There was a problem hiding this comment.
I believe this concept of "without the ** modifier" is referred to as the "natural **", for example "natural alignment". I think it would be good to introduce such terms earlier (when we first start to speak about alignment) and then use them.
src/type-layout.md
Outdated
| The packing value is specified as an integer parameter in the form of | ||
| `#[repr(packed(x))]`. If no value is given, as in `#[repr(packed)]`, then the | ||
| packing value is 1. The packing value must be a power of two from 1 up to | ||
| 2<sup>29</sup>. |
There was a problem hiding this comment.
If you extract out the wording about the default it is the same as the paragraph for align. So extract these two out into a common notion repr_value or something and then reference that one.
Co-Authored-By: ehuss <eric@huss.org>
|
I attempted to reduce some of the duplication. It still seems a little awkward, though. |
|
I think this is strict improvement for now. Thanks @ehuss. |
|
Technically it would be more accurate to say |
|
@retep998 Could you file a clarification PR? |
Update books ## nomicon 1 commits in f1ff93b66844493a7b03101c7df66ac958c62418..c02e0e7754a76886e55b976a3a4fac20100cd35d 2019-02-26 13:37:28 -0500 to 2019-03-25 16:52:56 -0400 - dropck: The drop order is now defined (rust-lang/nomicon#113) ## reference 3 commits in 27ad493..98f90ff 2019-03-26 02:06:15 +0100 to 2019-04-06 09:29:08 -0700 - Document repr packed(N). (rust-lang/reference#553) - Fix broken link in glossary. (rust-lang/reference#558) - Typo fixes (rust-lang/reference#556) ## embedded-book 2 commits in 07fd3880ea0874d82b1d9ed30ad3427ec98b4e8a..7989c723607ef5b13b57208022259e6c771e11d0 2019-03-27 15:40:52 +0000 to 2019-04-04 12:14:37 +0000 - fix rust-embedded/book#182 (rust-embedded/book#183) - Add openocd to list of installable packages (rust-embedded/book#179)
Update books ## nomicon 1 commits in f1ff93b66844493a7b03101c7df66ac958c62418..c02e0e7754a76886e55b976a3a4fac20100cd35d 2019-02-26 13:37:28 -0500 to 2019-03-25 16:52:56 -0400 - dropck: The drop order is now defined (rust-lang/nomicon#113) ## reference 3 commits in 27ad493..98f90ff 2019-03-26 02:06:15 +0100 to 2019-04-06 09:29:08 -0700 - Document repr packed(N). (rust-lang/reference#553) - Fix broken link in glossary. (rust-lang/reference#558) - Typo fixes (rust-lang/reference#556) ## embedded-book 2 commits in 07fd3880ea0874d82b1d9ed30ad3427ec98b4e8a..7989c723607ef5b13b57208022259e6c771e11d0 2019-03-27 15:40:52 +0000 to 2019-04-04 12:14:37 +0000 - fix rust-embedded/book#182 (rust-embedded/book#183) - Add openocd to list of installable packages (rust-embedded/book#179)
Closes #483
I feel like this is lacking, but I'm not sure what else to add.