close
Skip to content

Better docs for PartialEq (includes macro rename)#156144

Open
hkBst wants to merge 1 commit into
rust-lang:mainfrom
hkBst:improve-partial-eq-docs
Open

Better docs for PartialEq (includes macro rename)#156144
hkBst wants to merge 1 commit into
rust-lang:mainfrom
hkBst:improve-partial-eq-docs

Conversation

@hkBst
Copy link
Copy Markdown
Member

@hkBst hkBst commented May 4, 2026

No description provided.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 4, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 4, 2026

r? @nia-e

rustbot has assigned @nia-e.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @scottmcm, libs
  • @scottmcm, libs expanded to 8 candidates
  • Random selection from Mark-Simulacrum, jhpratt, nia-e, scottmcm

Comment thread library/core/src/cmp.rs
fn eq(&self, other: &Rhs) -> bool;

/// Tests for `!=`. The default implementation is almost always sufficient,
/// and should not be overridden without very good reason.
Copy link
Copy Markdown
Member

@nia-e nia-e May 4, 2026

Choose a reason for hiding this comment

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

This warning should probably remain in some form

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've now tried to reword to mention the few cases where it could make sense to override (line 269).

Comment thread library/core/src/cmp.rs Outdated
/// Implements `PartialEq` for primitive types.
///
/// Primitive types have a compiler-defined primitive implementation of `==` and `!=`.
/// This implements the `PartialEq` trait is terms of those primitive implementations.
Copy link
Copy Markdown
Member

@nia-e nia-e May 4, 2026

Choose a reason for hiding this comment

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

typo: "trait [in] terms of"

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, fixed.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 4, 2026
@nia-e
Copy link
Copy Markdown
Member

nia-e commented May 4, 2026

Looks mostly fine, just a few comments. Thanks!

@rust-cloud-vms rust-cloud-vms Bot force-pushed the improve-partial-eq-docs branch from a52171b to d3db8b5 Compare May 4, 2026 16:32
@rust-cloud-vms rust-cloud-vms Bot force-pushed the improve-partial-eq-docs branch from d3db8b5 to f25a255 Compare May 5, 2026 08:04
@hkBst
Copy link
Copy Markdown
Member Author

hkBst commented May 6, 2026

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 6, 2026
@hkBst hkBst changed the title Better docs for PartialEq Better docs for PartialEq (includes macro rename) May 8, 2026
Comment thread library/core/src/cmp.rs
/// The default implementation of the inequality operator simply calls
/// the implementation of the equality operator and negates the result.
///
/// Override the default when forwarding to another PartialEq implementation,
Copy link
Copy Markdown
Member

@nia-e nia-e May 12, 2026

Choose a reason for hiding this comment

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

Suggested change
/// Override the default when forwarding to another PartialEq implementation,
/// This default shouldn't be overriden without very good reason, such as when

View changes since the review

Copy link
Copy Markdown
Member Author

@hkBst hkBst May 12, 2026

Choose a reason for hiding this comment

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

I'm happy to go with this, but I'm not convinced we really need this strong warning. In fact I'm not convinced we really need a warning at all here, as nothing really bad can happen when overriding the default (except for getting it wrong accidentally). In fact we seem to prefer to override the default for forwarding implementations for only a small win.

@fee1-dead I would appreciate your perspective on this.

Comment thread library/core/src/cmp.rs
/// the implementation of the equality operator and negates the result.
///
/// Override the default when forwarding to another PartialEq implementation,
/// and maybe when using FFI or inline assembly for its implementation.
Copy link
Copy Markdown
Member

@nia-e nia-e May 12, 2026

Choose a reason for hiding this comment

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

Suggested change
/// and maybe when using FFI or inline assembly for its implementation.
/// forwarding to another implementation.

View changes since the review

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 12, 2026
@nia-e
Copy link
Copy Markdown
Member

nia-e commented May 12, 2026

r=me if the changes seem reasonable, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants