Description
This is a tracking issue for the RFC "Transparent Unions and Enums" (rust-lang/rfcs#2645).
Steps:
- Implement the RFC (cc @rust-lang/compiler -- can anyone write up mentoring instructions?)
- Adjust documentation (see instructions on forge)
- Stabilization PR (see instructions on forge) [done for enums]
Unresolved questions:
The role of
#[repr(transparent)]
in nonnull-style optimizations is not entirely clear. Specifically, it is unclear whether the user can rely on these optimizations to be performed when they make a type transparent. Transparentunion
s somewhat complicate the matter. General concensus seems to be that the compiler is free to decide where and when to perform nonnull-style optimizations onunion
s (regardless of whether or not theunion
is transaprent), and no guarantees are made to the user about when and if those optimizations will be applied. It is still an open question exactly what guarantees (if any) Rust makes about transparentstruct
s (andenum
s) and nonnull-style optimizations.This RFC doesn't propose any changes to transparent
struct
s, and so does not strictly depend on this question being resolved. But since this RFC is attempting to round out the#[repr(transparent)]
feature, it seems reasonable to dedicate some time to attempting to round out the guarantees about#[repr(transparent)]
onstruct
s.
Also it is not clear if transparent unions can even be implemented on LLVM without seriously restricting our semantics for unions overall.