Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading description of PartialEq derived implementation for enums in docs #97945

Closed
nirvana-msu opened this issue Jun 10, 2022 · 2 comments · Fixed by #97950
Closed

Misleading description of PartialEq derived implementation for enums in docs #97945

nirvana-msu opened this issue Jun 10, 2022 · 2 comments · Fixed by #97950
Assignees
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@nirvana-msu
Copy link

nirvana-msu commented Jun 10, 2022

Current docs on PartialEq derive state:

When derived on enums, each variant is equal to itself and not equal to the other variants.

I interpret the above statement as "PartialEq compares enum discriminants", which is not the case.

This is true for enums variants with no data, however for enum variants that are struct-like or tuple struct-like, derived PartialEq actually compares the fields (which is expected) and not just discriminants:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=64530ce03a4506d1e82a1df4d78765ff

@eggyal
Copy link
Contributor

eggyal commented Jun 10, 2022

@rustbot label: +A-docs +C-cleanup +E-easy +T-libs-api

@rustbot rustbot added A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Jun 10, 2022
@eggyal
Copy link
Contributor

eggyal commented Jun 10, 2022

@rustbot claim

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jun 12, 2022
compiler-errors added a commit to compiler-errors/rust that referenced this issue Jun 13, 2022
@bors bors closed this as completed in 7bbf914 Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants