Skip to content

Add a lint about deriving Hash and implementing PartialEq #571

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

Merged
merged 1 commit into from
Jan 22, 2016

Conversation

mcarton
Copy link
Member

@mcarton mcarton commented Jan 21, 2016

Fix #430.

/// **What it does:** This lint warns about deriving `Hash` but implementing `PartialEq`
/// explicitely.
///
/// **Why is this bad?** The implementation of these traits must agree so it’s probably a bad idea
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have a more detailed explanation here? cc @gankro

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem. Is it better?

/// **Why is this bad?** The implementation of these traits must agree (for example for use with
/// `HashMap`) so it’s probably a bad idea to use a default-generated `Hash` implementation with
/// an explicitely defined `PartialEq`. In particular, the following must hold for any type:
/// ```rust
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be a linebreak before this

Manishearth added a commit that referenced this pull request Jan 22, 2016
Add a lint about deriving Hash and implementing PartialEq
@Manishearth Manishearth merged commit 6d60b3d into rust-lang:master Jan 22, 2016
@Manishearth
Copy link
Member

We can also do something similar for Copy and Clone btw.

@mcarton mcarton deleted the hash_eq branch January 22, 2016 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants