Skip to content

Commit a16c846

Browse files
committed
say more clearly what is still being debated
1 parent 4cd1833 commit a16c846

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/behavior-considered-undefined.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,18 @@ Whether a value is valid depends on the type:
143143
* A `str` value is treated like `[u8]`, i.e. it must be initialized.
144144
* An `enum` must have a valid discriminant, and all fields of the variant indicated by that discriminant must be valid at their respective type.
145145
* A `struct`, tuple, and array requires all fields/elements to be valid at their respective type.
146-
* For a `union`, the exact validity requirements are not decided yet. The following is certain:
147-
* If the `union` has a zero-sized field, then all values are valid.
148-
* If a value is valid for a particular `union` field, then it is valid for the union.
146+
* For a `union`, the exact validity requirements are not decided yet.
147+
Obviously, all values that can be created entirely in safe code are valid.
148+
If the union has a zero-sized field, then every possible value is valid.
149+
Further details are [still being debated](https://github.com/rust-lang/unsafe-code-guidelines/issues/438).
149150
* A reference or [`Box<T>`] must be aligned, it cannot be [dangling], and it must point to a valid value
150151
(in case of dynamically sized types, using the actual dynamic type of the
151152
pointee as determined by the metadata).
153+
Note that the last point (about pointing to a valid value) is still subject of debate.
152154
* The metadata of a wide reference, [`Box<T>`], or raw pointer must match
153155
the type of the unsized tail:
154156
* `dyn Trait` metadata must be a pointer to a compiler-generated vtable for `Trait`.
157+
(For raw pointers, this requirement is still subject of debate.)
155158
* Slice (`[T]`) metadata must be a valid `usize`.
156159
Furthermore, for wide references and [`Box<T>`], slice metadata is invalid
157160
if it makes the total size of the pointed-to value bigger than `isize::MAX`.

0 commit comments

Comments
 (0)