Skip to content

Conversation

@samueltardieu
Copy link
Member

@samueltardieu samueltardieu commented Oct 23, 2025

The Deref trait is already as lang item, there is no need for it to be a diagnostic item as well.

r? lcnr

@rustbot
Copy link
Collaborator

rustbot commented Oct 23, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. 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 Oct 23, 2025
@samueltardieu
Copy link
Member Author

samueltardieu commented Oct 23, 2025

@lcnr I r?'ed you because of #147643

@rust-lang rust-lang deleted a comment from rustbot Oct 23, 2025
@lqd lqd changed the title Remove the sym::Defer diagnostic item Remove the sym::Deref diagnostic item Oct 23, 2025
Copy link
Member

@hkBst hkBst left a 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.

View changes since this review

The `Deref` trait is already as lang item, there is no need for it to be a diagnostic item as well.
@samueltardieu samueltardieu force-pushed the cleanups/defer-diag-item branch from 9d89069 to 8275f31 Compare October 23, 2025 18:29
@samueltardieu
Copy link
Member Author

Looks good to me.

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 (DeferDeref).

@hkBst
Copy link
Member

hkBst commented Oct 24, 2025

Looks good to me.

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 (DeferDeref).

That was @lqd. I admit that I did not review the commit messages... :)

Copy link
Contributor

@lcnr lcnr left a 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

View changes since this review

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_,
Copy link
Contributor

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 🤔

Copy link
Member

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes

Copy link
Member Author

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

@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 Oct 24, 2025
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-clippy Relevant to the Clippy team. 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.

4 participants