-   Notifications  You must be signed in to change notification settings 
- Fork 13.9k
 Remove the sym::Deref diagnostic item #148033 
 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
base: master
Are you sure you want to change the base?
  Remove the sym::Deref diagnostic item  #148033 
 Conversation
| Some changes occurred in src/tools/clippy cc @rust-lang/clippy | 
sym::Defer diagnostic itemsym::Deref diagnostic item 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.
Looks good to me.
The `Deref` trait is already as lang item, there is no need for it to be a diagnostic item as well.
9d89069 to 8275f31   Compare   | 
 You fixing the typo in the PR title made me notice it was present (twice!) in the commit message. I've pushed a commit with the typo fixed ( | 
| 
 That was @lqd. I admit that I did not review the commit messages... :) | 
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.
looking at the changes, while I think avoiding duplication between diagnostic and lang items is good, the changes themselves are... not amazing.
I feel like ideally code shouldn't have to care about the difference between lang and diagnostics items. What are the meaningful differences between em
- lang item use an enum preventing accidentally referring to an item that doesn't actually exist, while diagnostic items theoretically allow being introduced in third party crates without rustc knowing about it (just for clippy)
- being a diagnostic item should not impact happy path behavior in any way. it should only matter for diagnostics, while lang items are more interesting as they also impact semantics
I guess this is fine and don't have a great suggestion here. I think some API which fetches either the diagnostic or the lang item name would be nice so that the set of diagnostic items is always a super set of all lang items. But 🤷 on how to do that and think it doesn't have to happen rn. Would be happy if you (or somebody else) wants to look into that separately from this PR
| if !matches!(trait_, sym::Borrow | sym::Clone | sym::Deref) { | ||
| return; | ||
| let trait_ = match cx.tcx.get_diagnostic_name(trait_id) { | ||
| Some(trait_ @ (sym::Borrow | sym::Clone)) => trait_, | 
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.
the same is also true for Clone 🤔
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.
the same as in Clone is also both langitem and diagitem? And so should perhaps lose its diagitem status?
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.
yes
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.
I'll propose a unified way in this PR.
 @rustbot author
The
Dereftrait is already as lang item, there is no need for it to be a diagnostic item as well.r? lcnr