-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add a "diagnostic item" scheme for lints referring to libstd items #60966
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #61044) made this pull request unmergeable. Please resolve the merge conflicts. |
@rust-lang/compiler Are you alright with adding this scheme (similar to lang items) for diagnostic items, allowing rustc lints and clippy lints to ask the compiler whether a specific |
Is there an overview somewhere of what "diagnostic items" are and why the concept is needed? |
The list of things that we want to make diagnostic items include (but are not limited to) https://github.com/rust-lang/rust-clippy/blob/abe139c7ac7d5a33a6edb60ba0d4eb4dfaf11103/clippy_lints/src/utils/paths.rs#L4-L115 Now our scheme (of using
Furthermore, some rustc diagnostics have to go through pretty printing types and matching on the result like in rust/src/librustc_mir/borrow_check/move_errors.rs Lines 317 to 322 in ed2a511
This PR will allow making all of these libcore/libstd specific errors and lints much simpler and reduce the complexity needed around them. |
☔ The latest upstream changes (presumably #60827) made this pull request unmergeable. Please resolve the merge conflicts. |
@oli-obk You can always look up the But I am not strongly in favor of either, sometimes I'd rather |
Note that lookups are pretty slow compared to this scheme. I would like to expose name resolution machinery, though, we need that anyway for rustdoc.
It would need to behave exactly the same way Option does in the contexts any given lint cares about, so pattern matching that ("does it have a function named X?" etc) gets much more expensive |
@Manishearth I agree about pattern-matching requiring custom logic, which has a time/effort cost to write in the first place - however, the cost to run a lookup/pattern-match is easily amortized by caching. |
I want to add a scheme like Note that this change is done out of three reasons:
tbh, the last three are why I did this |
☔ The latest upstream changes (presumably #61276) made this pull request unmergeable. Please resolve the merge conflicts. |
Heh, one idea I just had: We can pattern match definitions and suggest that the user add |
ping from triage @Manishearth @oli-obk any updates? |
📌 Commit 26e9990 has been approved by |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors r- PR builder is unhappy ^-- |
@bors r=eddyb |
📌 Commit 6978b94 has been approved by |
Add a "diagnostic item" scheme for lints referring to libstd items fixes #39131 r? @Manishearth @rust-lang/wg-diagnostics
☀️ Test successful - checks-azure |
📣 Toolstate changed by #60966! Tested on commit c7d4df0. 💔 clippy-driver on windows: test-pass → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk @phansch @flip1995, @rust-lang/infra). |
Tested on commit rust-lang/rust@c7d4df0. Direct link to PR: <rust-lang/rust#60966> 💔 clippy-driver on windows: test-pass → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk @phansch @flip1995, @rust-lang/infra). 💔 clippy-driver on linux: test-pass → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk @phansch @flip1995, @rust-lang/infra). 💔 rls on linux: test-pass → test-fail (cc @Xanewok, @rust-lang/infra).
Rustup to rust-lang/rust#60966 changelog: none
Rustup to rust-lang/rust#60966 changelog: none
fixes #39131
r? @Manishearth @rust-lang/wg-diagnostics