Skip to content

Conversation

@TmSalviano
Copy link
Contributor

@TmSalviano TmSalviano commented Mar 4, 2025

Zero-variant enums and the never type are not equivalent.

None of them can be instantiated since they have no possible values, but:

  1. Only the ! type can be coerced into any other type. (this, by itself, already invalidates any claims of equivalence)
  2. The ! type has a very well defined use case and semantical meaning in the language itself: represent the result of computations that never complete. At best, Zero-variant enums can have user-defined semantical meaning inside a program when implemented by the developer which, if it's a sound implementation, will be closely related to it's defining property: "a type that has no possible values".

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Mar 4, 2025
@traviscross
Copy link
Contributor

Thanks for the suggestion. Your points 1 and 2 are correct, of course. And there's probably a better way that we could state this overall. There are a lot of tricky behaviors here.

Still, in context, we think the existing language is actually OK here. It says it's "equivalent, but...". I.e., it's not exactly equivalent. And that's fine. That's how language is sometimes.

So we're going to close this, but we'll keep this in mind if we ever take a pass at changing this in other ways.

@traviscross traviscross closed this Mar 4, 2025
@TmSalviano TmSalviano deleted the no_equivalence_fix branch March 11, 2025 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: The marked PR is awaiting review from a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants