@@ -143,15 +143,18 @@ Whether a value is valid depends on the type:
143
143
* A ` str ` value is treated like ` [u8] ` , i.e. it must be initialized.
144
144
* An ` enum ` must have a valid discriminant, and all fields of the variant indicated by that discriminant must be valid at their respective type.
145
145
* 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 ) .
149
150
* A reference or [ ` Box<T> ` ] must be aligned, it cannot be [ dangling] , and it must point to a valid value
150
151
(in case of dynamically sized types, using the actual dynamic type of the
151
152
pointee as determined by the metadata).
153
+ Note that the last point (about pointing to a valid value) is still subject of debate.
152
154
* The metadata of a wide reference, [ ` Box<T> ` ] , or raw pointer must match
153
155
the type of the unsized tail:
154
156
* ` 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.)
155
158
* Slice (` [T] ` ) metadata must be a valid ` usize ` .
156
159
Furthermore, for wide references and [ ` Box<T> ` ] , slice metadata is invalid
157
160
if it makes the total size of the pointed-to value bigger than ` isize::MAX ` .
0 commit comments