-
-
Notifications
You must be signed in to change notification settings - Fork 17.7k
Unions with ZSTs are no longer usable #59126
Copy link
Copy link
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.P-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Description
Activity
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.P-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
It looks like this was broken in the release of 1.32.0 (and is still broken, even on nightly) (checked on https://rust.godbolt.org/). The following example program:
Fails to compile:
Interestingly, making the
union#[repr(C)]fixes it.My Rust version:
I know
unionfield accesses aren't stable, but I don't think this qualifies as a field access. And yes, I'm aware ofMaybeUninit.cc @RalfJung