From 3905456bba2e88f48f00b789d21e9bf7ce8560ee Mon Sep 17 00:00:00 2001 From: George Bateman Date: Tue, 24 Dec 2024 20:32:30 +0000 Subject: [PATCH 1/3] Correct repr(Rust) overlapping fields rule for enums and unions --- src/type-layout.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/type-layout.md b/src/type-layout.md index 5d04d2a80..fa1aa9baa 100644 --- a/src/type-layout.md +++ b/src/type-layout.md @@ -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] @@ -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 From e3cc0c539a27bde97a8e2e27837999e330ffa49e Mon Sep 17 00:00:00 2001 From: George Bateman Date: Fri, 27 Dec 2024 15:12:08 +0000 Subject: [PATCH 2/3] Update coverage-instrumentation.md CI broken, presumably by https://github.com/rust-lang/rust/pull/134672. --- src/attributes/coverage-instrumentation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/attributes/coverage-instrumentation.md b/src/attributes/coverage-instrumentation.md index 8fbec0fbe..8f361ae9a 100644 --- a/src/attributes/coverage-instrumentation.md +++ b/src/attributes/coverage-instrumentation.md @@ -20,6 +20,8 @@ The attribute uses the [_MetaListIdents_] syntax to specify its behavior: * `#[coverage(on)]` (the default) indicates that all functions within an item, recursively, *should* be instrumented, unless specified by another attribute. ```rust +#![feature(coverage_attribute)] + #[coverage(off)] fn example() {} From c40d8aad002c830a0936b01a61db677466604395 Mon Sep 17 00:00:00 2001 From: George Bateman Date: Fri, 27 Dec 2024 15:17:30 +0000 Subject: [PATCH 3/3] Update coverage-instrumentation.md --- src/attributes/coverage-instrumentation.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/attributes/coverage-instrumentation.md b/src/attributes/coverage-instrumentation.md index 8f361ae9a..7e90299d1 100644 --- a/src/attributes/coverage-instrumentation.md +++ b/src/attributes/coverage-instrumentation.md @@ -19,9 +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 -#![feature(coverage_attribute)] - +```rust,ignore #[coverage(off)] fn example() {}