Untagged unions (tracking issue for RFC 1444) · Issue #32836 · rust-lang/rust (original) (raw)
Tracking issue for rust-lang/rfcs#1444.
Unresolved questions:
- Does assigning directly to a union field trigger a drop of the previous contents?
- When moving out of one field of a union, are the others considered invalidated? (1, 2, 3, 4)
- Answered by Union initialization and Drop rfcs#2514.
- Under what conditions can you implement
Copy
for a union? For example, what if some variants are of non-Copy type? All variants? - What interaction is there between unions and enum layout optimizations? (Unions interacting with Enum layout optimization #36394)
Open issues of high import:
- Matching on uninhabited unsafe places (union fields, raw pointer dereferences, etc.) allowed in safe code. #47412 -- MIR-based unsafety checker sometimes accepts unsafe accesses to union fields in presence of uninhabited fields