Make opsem for all enums consistent, independent of number of variants and `#[non_exhaustive]`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
The way we generate MIR currently means that enum opsem distinguished two classes of enums
- Those with more than 1 variant or a
#[non_exhaustive]attribute - Those with 1 or 0 variants and no
#[non_exhaustive]
For the latter, we sometimes omit reading the discriminant since we "already know the result". Also see https://github.com/rust-lang/rust/pull/150681 where this is point 1.
I think we should treat all enums consistently. This example should be considered UB. In particular, I think #[non_exhaustive] should not affect the opsem.
This change was separated out of https://github.com/rust-lang/rust/pull/150681 at the request of @traviscross, so that it can be discussed separately. So, let's discuss. :) @scottmcm and @nikomatsakis already expressed agreement with this next step in that PR.
Cc @meithecatte -- IIRC this had a non-zero crater fallout; where are the results of that again?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the linked Rust PR #150681, the playground example, and the MIR opsem discussion, including the referenced crater fallout. A complete contribution requires a settled decision on consistent enum discriminant semantics, followed by implementation and validation that the example is treated as UB without special handling for variant count or #[non_exhaustive].
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100