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

derive_partial_eq_without_eq will trigger for third party crate derives #9320

Open
Tracked by #79
yoav-lavi opened this issue Aug 11, 2022 · 2 comments
Open
Tracked by #79
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have L-nursery Lint: Currently in the nursery group T-macros Type: Issues with macros and macro expansion

Comments

@yoav-lavi
Copy link
Contributor

yoav-lavi commented Aug 11, 2022

Summary

error: you are deriving `PartialEq` and can implement `Eq`
  --> my/project/folder/mod.rs:90:48
   |
90 |         #[derive(third_party::Trait, Debug)]
   |                  ^^^^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
   = note: this error originates in the derive macro `third_party::Trait` (in Nightly builds, run with -Z macro-backtrace for more info)

derive_partial_eq_without_eq seems to trigger for proc macro derives from third party crates which adds PartialEq but not Eq, which while a user can theoretically add an implementation for / derive Eq as well, it could cause breakage when the crate author updates and adds the missing implementation / derive as well

Reproducer

I tried this code:

#[derive(third_party::Trait, Debug)]

I expected to see this happen: No lint error

Instead, this happened: A lint error for derive_partial_eq_without_eq

Version

rustc 1.63.0 (4b91a6ea7 2022-08-08)
binary: rustc
commit-hash: 4b91a6ea7258a947e59c6522cd5898e7c0a6a88f
commit-date: 2022-08-08
host: aarch64-apple-darwin
release: 1.63.0
LLVM version: 14.0.5

Additional Labels

No response

@yoav-lavi yoav-lavi added the C-bug Category: Clippy is not doing the correct thing label Aug 11, 2022
@xFrednet xFrednet added T-macros Type: Issues with macros and macro expansion I-false-positive Issue: The lint was triggered on code it shouldn't have labels Sep 25, 2022
@J-ZhengLi
Copy link
Member

@rustbot claim

@J-ZhengLi J-ZhengLi removed their assignment Dec 26, 2023
@GuillaumeGomez
Copy link
Member

Adding some context fore anyone who would want to try to fix this: in LateContext, the derive attributes don't exist anymore as they were already expanded, making it very tricky to actually check if the type has #[derive(PartialEq)]. A solution would be to actually parse the source code, starting from Span::lo of the type and going back until you finda stop character (like } or ;). This is quite tricky to do though, so not an easy fix.

@J-ZhengLi J-ZhengLi added the L-nursery Lint: Currently in the nursery group label Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have L-nursery Lint: Currently in the nursery group T-macros Type: Issues with macros and macro expansion
Projects
None yet
Development

No branches or pull requests

4 participants