Uh oh!
There was an error while loading. Please reload this page.
Add diagnostic items for Clippy - #87170
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
xFrednet
commented
Jul 15, 2021
The pipeline shows why some diagnostic items use |
camsteffen
commented
Jul 15, 2021
I would just add diagnostic items for modules Aside: I am looking into adding a new lookup util so we can write code like |
Such a lookup macro would be awesome, btw. |
Manishearth
commented
Jul 15, 2021
Hmm, but doesn't that bring us closer to what we used to have? Seems faster and cleaner to just have diagnostic items for everyone.
Yeah, sure! |
Manishearth
commented
Jul 15, 2021
cc @estebank |
22e152c to
3d5453fCompareThere was a problem hiding this comment.
| #[cfg_attr(not(test), rustc_diagnostic_item = "HashmapEntry")] | |
| #[cfg_attr(not(test), rustc_diagnostic_item = "HashMapEntry")] |
3d5453f to
37626f3Compare37626f3 to
d38f2b0Comparecamsteffen
commented
Jul 15, 2021
I recommend that only because some functions are very closely tied to the module they are in. |
This comment has been minimized.
This comment has been minimized.
Manishearth
left a comment
There was a problem hiding this comment.
Maybe someone from @rust-lang/compiler can make sure we're not doing anything wrong here
camsteffen
commented
Jul 15, 2021
It would work with associated types, associated methods, inherent methods, module items, ... lookup!(HashMap)lookup!(HashMap::Entry)lookup!(HashMap::insert)lookup!(Iterator::find)lookup!(cmp::min) |
xFrednet
commented
Jul 15, 2021
I definitely like the idea. Note that it probably wouldn't work for Using the parent search method would probably still not fully work for reexports though. |
Manishearth
commented
Jul 15, 2021
Right, part of the reason behind having diagnostic items is never having to know the internal organization of the crate. It makes sense to do parent lookups for methods/etc but not as much for free functions |
oli-obk
commented
Jul 16, 2021
@bors r=Manishearth,oli-obk |
bors
commented
Jul 16, 2021
📌 Commit d38f2b0 has been approved by |
oli-obk
commented
Jul 16, 2021
for future reference on method lookups of traits/impls: https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/Diagnostic.20Item.20Naming.20Convention.3F |
Would it maybe be worth it to implement a function/macro like My understanding is that paths in use statements resolve to the original Has there been any previous discussions about a concept like this? Edit: @oli-obk thanks for posting the link again, should we move the discussion over to Zulip? 🙃 |
xFrednet
commented
Jul 16, 2021
I've created a Zulip topic with a short summary here: https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/Use.20of.20diagnostic.20items.20.28discussion.20from.20rust.2387170.29/near/246219798 |
Manishearth
commented
Jul 16, 2021
The point of diagnostic items was, in part, to not have to do any such lookups: I don't see what problem it solves to switch from diagnostic items to lookups. |
xFrednet
commented
Jul 16, 2021
My understanding was that the main point of diagnostic items was to avoid hard coded paths to the exact item. That problem would be solved, and it would make a slightly nicer interface IMO. But that's it. There has also been some feedback on Zulip that using the resolver for this can be problematic and produce ICEs. I'll dig a bit more through the compiler, but it seems like diagnostic items are a currently the best solution. |
…-items, r=Manishearth,oli-obk Add diagnostic items for Clippy This adds a bunch of diagnostic items to `std`/`core`/`alloc` functions, structs and traits used in Clippy. The actual refactorings in Clippy to use these items will be done in a different PR in Clippy after the next sync. This PR doesn't include all paths Clippy uses, I've only gone through the first 85 lines of Clippy's [`paths.rs`](https://github.com/rust-lang/rust-clippy/blob/ecf85f4bdc319f9d9d853d1fff68a8a25e64c7a8/clippy_utils/src/paths.rs) (after rust-lang/rust-clippy#7466) to get some feedback early on. I've also decided against adding diagnostic items to methods, as it would be nicer and more scalable to access them in a nicer fashion, like adding a `is_diagnostic_assoc_item(did, sym::Iterator, sym::map)` function or something similar (Suggested by `@camsteffen` [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/Diagnostic.20Item.20Naming.20Convention.3F/near/225024603)) There seems to be some different naming conventions when it comes to diagnostic items, some use UpperCamelCase (`BinaryHeap`) and some snake_case (`hashmap_type`). This PR uses UpperCamelCase for structs and traits and snake_case with the module name as a prefix for functions. Any feedback on is this welcome. cc: rust-lang/rust-clippy#5393 r? `@Manishearth`
GuillaumeGomez
commented
Jul 16, 2021
@bors: r- |
Sorry, that I didn't fix the error earlier, the error message confused me at first. Now everything should hopefully be correct 🙃 |
oli-obk
commented
Jul 17, 2021
@bors r=Manishearth,oli-obk |
bors
commented
Jul 17, 2021
📌 Commit 67002db has been approved by |
Rollup of 8 pull requests Successful merges: - rust-lang#86763 (Add a regression test for issue-63355) - rust-lang#86814 (Recover from a misplaced inner doc comment) - rust-lang#86843 (Check that const parameters of trait methods have compatible types) - rust-lang#86889 (rustdoc: Cleanup ExternalCrate) - rust-lang#87092 (Remove nondeterminism in multiple-definitions test) - rust-lang#87170 (Add diagnostic items for Clippy) - rust-lang#87183 (fix typo in compile_fail doctest) - rust-lang#87205 (rustc_middle: remove redundant clone) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This adds a bunch of diagnostic items to
std/core/allocfunctions, structs and traits used in Clippy. The actual refactorings in Clippy to use these items will be done in a different PR in Clippy after the next sync.This PR doesn't include all paths Clippy uses, I've only gone through the first 85 lines of Clippy's
paths.rs(after rust-lang/rust-clippy#7466) to get some feedback early on. I've also decided against adding diagnostic items to methods, as it would be nicer and more scalable to access them in a nicer fashion, like adding ais_diagnostic_assoc_item(did, sym::Iterator, sym::map)function or something similar (Suggested by @camsteffenon Zulip)There seems to be some different naming conventions when it comes to diagnostic items, some use UpperCamelCase (
BinaryHeap) and some snake_case (hashmap_type). This PR uses UpperCamelCase for structs and traits and snake_case with the module name as a prefix for functions. Any feedback on is this welcome.cc: rust-lang/rust-clippy#5393
r? @Manishearth