Skip to content

clippy fix: remove manual PartialEq::ne #143377

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hkBst
Copy link
Member

@hkBst hkBst commented Jul 3, 2025

Removes manual impls of PartialEq::ne which are equivalent to the default.

@rustbot
Copy link
Collaborator

rustbot commented Jul 3, 2025

r? @tgross35

rustbot has assigned @tgross35.
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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 3, 2025
@taiki-e
Copy link
Member

taiki-e commented Jul 3, 2025

equivalent to the default

Note that implementations for reference types are not strictly the same as the default because they are forwarding of the underlying implementation. In such cases, if the compiler cannot optimize the inversion of the result from the underlying implementation (e.g., inline assembly or FFI is used), then ne may generate an extra 1-2 instructions (xor with constant 1 or set constant 1 to the register and xor with it).

@hkBst
Copy link
Member Author

hkBst commented Jul 3, 2025

@taiki-e that is a good point, thanks!

@rust-log-analyzer

This comment has been minimized.

Comment on lines +2027 to +2029
// if <A as PartialEq<B>>::ne uses inline assembly or FFI, then
// this forwarding impl may be more efficient than the default impl
#[allow(clippy::partialeq_ne_impl)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably allow->expect so we get a bit of noise if these change for some reason.

Maybe just make this a module-level attribute? Since it applies to all but one fn ne in this file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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.

5 participants