Skip to content

Make opsem for all enums consistent, independent of number of variants and #[non_exhaustive] #151786

@RalfJung

Description

@RalfJung

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 #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 #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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-closuresArea: Closures (`|…| { … }`)A-patternsRelating to patterns and pattern matchingC-bugCategory: This is a bug.I-lang-radarItems that are on lang's radar and will need eventual work or consideration.T-langRelevant to the language teamT-opsemRelevant to the opsem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions