Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct repr(Rust) overlapping fields rule for enums and unions #1704

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/attributes/coverage-instrumentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The attribute uses the [_MetaListIdents_] syntax to specify its behavior:
* `#[coverage(off)]` indicates that all functions within an item, recursively, should not be instrumented, unless specified by another attribute.
* `#[coverage(on)]` (the default) indicates that all functions within an item, recursively, *should* be instrumented, unless specified by another attribute.

```rust
```rust,ignore
#[coverage(off)]
fn example() {}

Expand Down
5 changes: 3 additions & 2 deletions src/type-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ The only data layout guarantees made by this representation are those required
for soundness. They are:

1. The fields are properly aligned.
2. The fields do not overlap.
2. For structs, within each enum variant, and excluding unions, the fields do not overlap.
3. The alignment of the type is at least the maximum alignment of its fields.

r[layout.repr.rust.alignment]
Expand All @@ -235,7 +235,8 @@ The second guarantee means that the fields can be
ordered such that the offset plus the size of any field is less than or equal to
the offset of the next field in the ordering. The ordering does not have to be
the same as the order in which the fields are specified in the declaration of
the type.
the type. This applies within each variant of an enum, but fields of
different variants may overlap.

Be aware that the second guarantee does not imply that the fields have distinct
addresses: zero-sized types may have the same address as other fields in the
Expand Down
Loading