From 0765586eb1692498930ae9f817fe759acbe8b237 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 6 Sep 2026 12:07:00 +0200 Subject: [PATCH 1/3] =?UTF-8?q?logic=20fix:=20and=20=E2=86=92=20or?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/behavior-considered-undefined.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/behavior-considered-undefined.md b/src/behavior-considered-undefined.md index ff34d0af28..10aacb0dba 100644 --- a/src/behavior-considered-undefined.md +++ b/src/behavior-considered-undefined.md @@ -139,7 +139,7 @@ r[undefined.validity.enum] * An `enum` must have a valid discriminant, and all fields of the variant indicated by that discriminant must be valid at their respective type. r[undefined.validity.struct] -* A `struct`, tuple, and array requires all fields/elements to be valid at their respective type. +* A `struct`, tuple, or array requires all fields/elements to be valid at their respective type. r[undefined.validity.union] * For a `union`, the exact validity requirements are not decided yet. Obviously, all values that can be created entirely in safe code are valid. If the union has a [zero-sized] field, then every possible value is valid. Further details are [still being debated](https://github.com/rust-lang/unsafe-code-guidelines/issues/438). From 13c985db964ad580a67657b4b7b4041134901425 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 6 Sep 2026 12:07:32 +0200 Subject: [PATCH 2/3] fix outdated reference to rustc_layout_scalar_valid_range --- src/behavior-considered-undefined.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/behavior-considered-undefined.md b/src/behavior-considered-undefined.md index 10aacb0dba..6099b28928 100644 --- a/src/behavior-considered-undefined.md +++ b/src/behavior-considered-undefined.md @@ -161,7 +161,7 @@ r[undefined.validity.valid-range] * If a type has a custom range of valid values, then a valid value must be in that range. In the standard library, this affects [`NonNull`] and [`NonZero`]. > [!NOTE] - > `rustc` achieves this with the unstable `rustc_layout_scalar_valid_range_*` attributes. + > `rustc` achieves this with pattern types (which are unstable). r[undefined.validity.const-provenance] * **In [const contexts]**: In addition to what is described above, further provenance-related requirements apply during const evaluation. Any value that holds pure integer data (the `i*`/`u*`/`f*` types as well as `bool` and `char`, enum discriminants, and slice [metadata]) must not carry any provenance. Any value that holds pointer data (references, raw pointers, function pointers, and `dyn Trait` metadata) must either carry no provenance, or all bytes must be fragments of the same original pointer value in the correct order. From 9d0c3cf07f674529aad05b6bbdda54d82962004f Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 6 Sep 2026 12:07:38 +0200 Subject: [PATCH 3/3] add missing links --- src/behavior-considered-undefined.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/behavior-considered-undefined.md b/src/behavior-considered-undefined.md index 6099b28928..5635fb16d6 100644 --- a/src/behavior-considered-undefined.md +++ b/src/behavior-considered-undefined.md @@ -145,11 +145,11 @@ r[undefined.validity.union] * For a `union`, the exact validity requirements are not decided yet. Obviously, all values that can be created entirely in safe code are valid. If the union has a [zero-sized] field, then every possible value is valid. Further details are [still being debated](https://github.com/rust-lang/unsafe-code-guidelines/issues/438). r[undefined.validity.reference-box] -* A reference or [`Box`] must be aligned and non-null, it cannot be [dangling], and it must point to a valid value (in case of dynamically sized types, using the actual dynamic type of the pointee as determined by the [metadata]). Note that the last point (about pointing to a valid value) remains a subject of some debate. +* A reference or [`Box`] must be aligned and non-null, it cannot be [dangling], and it must point to a valid value (in case of dynamically sized types, using the actual dynamic type of the pointee as determined by the [metadata]). Note that the last point (about pointing to a valid value) remains a subject of [some debate](https://github.com/rust-lang/unsafe-code-guidelines/issues/414). r[undefined.validity.wide] * The [metadata] of a wide reference, [`Box`], or raw pointer must match the type of the [unsized tail]: - * `dyn Trait` metadata must be a pointer to a compiler-generated vtable for `Trait`. (For raw pointers, this requirement remains a subject of some debate.) + * `dyn Trait` metadata must be a pointer to a compiler-generated vtable for `Trait`. (For raw pointers, this requirement remains a subject of [some debate](https://github.com/rust-lang/unsafe-code-guidelines/issues/516).) * Slice (`[T]`) and `str` metadata must be a valid `usize`. In addition, for a wide reference or [`Box`], the metadata is invalid if it makes the total size of the pointed-to value (as determined by `size_of_val`) bigger than `isize::MAX`.