Skip to content

update ancient note #113618

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 2 commits into from
Jul 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions library/std/src/collections/hash/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ use super::map::{map_try_reserve_error, RandomState};
/// ```
///
/// The easiest way to use `HashSet` with a custom type is to derive
/// [`Eq`] and [`Hash`]. We must also derive [`PartialEq`], this will in the
/// future be implied by [`Eq`].
/// [`Eq`] and [`Hash`]. We must also derive [`PartialEq`],
/// which is required if [`Eq`] is derived.
///
Copy link
Member

Choose a reason for hiding this comment

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

i don't think this change is correct. the note is saying "we have to derive PartialEq because Eq without PartialEq will error, and at some point we want to change derive(Eq) to imply derive(PartialEq)". that second half still isn't the case today — it's probably true that it's never going to happen, but i would expect the new comment to look a little different if that's what you meant.

Copy link
Member Author

Choose a reason for hiding this comment

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

I suspected that could be the case, but got confused by:

This property cannot be checked by the compiler, and therefore Eq implies PartialEq, and has no extra methods.

from https://doc.rust-lang.org/std/cmp/trait.Eq.html

I guess implies means something else in that example?

Copy link
Member

Choose a reason for hiding this comment

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

yes, unfortunately. the one here is using it to describe a behavior of the compiler and the one on the trait page is using it to describe a property of the language (that your code won't compile if you have Eq without PartialEq).

Copy link
Member Author

Choose a reason for hiding this comment

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

please see if latest wording is acceptable

/// ```
/// use std::collections::HashSet;
Expand Down