-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Only check for automatically_derived on impl blocks
#13055
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
Conversation
|
r? @Alexendoo rustbot has assigned @Alexendoo. Use |
clippy_utils/src/lib.rs
Outdated
| .find(|(_, node)| matches!(node, OwnerNode::Item(item) if matches!(item.kind, ItemKind::Impl(_)))) | ||
| .is_some_and(|(id, _)| { | ||
| has_attr( | ||
| tcx.hir().attrs(tcx.local_def_id_to_hir_id(id.def_id)), | ||
| sym::automatically_derived, | ||
| ) | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to keep going after the first impl? e.g. serde can generate Visitor impls inside the #[automatically_derived] Deserialize impl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds reasonable.
…ived`. Only check for the attribute on an impl block.
|
👍 @bors r+ |
|
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
This brings us in line with how rustc checks for the attribute. Also note that
unused_attributeswill trigger if it's placed anywhere else.See:
https://github.com/rust-lang/rust/blob/9a21ac8e7efe9ea26a8065d0959a976ca32039bb/compiler/rustc_passes/src/dead.rs#L400-L403
https://github.com/rust-lang/rust/blob/9a21ac8e7efe9ea26a8065d0959a976ca32039bb/compiler/rustc_passes/src/liveness.rs#L143-L148
changelog: none