-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Move our paths over to diagnostic items #5393
Comments
Marking it as tracking issue and pinning it, since this is probably done in multiple steps. |
…nishearth More diagnostic items for Clippy usage This adds a couple of more diagnostic items to be used in Clippy. I chose these particular ones because they were the types which we seem to check for the most in Clippy. I'm not sure if the `cfg_attr(not(test))` is needed, but it was also used for `Vec` and a few other types. cc rust-lang/rust-clippy#5393 r? @Manishearth
In particular for: * `VecDeque` * `String` * `Mutex` * `HashMap` * `HashSet` cc rust-lang/rust#71414 rust-lang#5393
Use more diagnostic items In particular for: * `VecDeque` * `String` * `Mutex` * `HashMap` * `HashSet` cc rust-lang/rust#71414 #5393 --- changelog: none
Use more diagnostic items In particular for: * `VecDeque` * `String` * `Mutex` * `HashMap` * `HashSet` cc rust-lang/rust#71414 #5393 --- changelog: none
In particular for: * `VecDeque` * `String` * `Mutex` * `HashMap` * `HashSet` cc rust-lang/rust#71414 rust-lang#5393
Use more diagnostic items In particular for: * `VecDeque` * `String` * `Mutex` * `HashMap` * `HashSet` cc rust-lang/rust#71414 #5393 --- changelog: none
Use more diagnostic items In particular for: * `VecDeque` * `String` * `Mutex` * `HashMap` * `HashSet` cc rust-lang/rust#71414 #5393 --- changelog: none
Use more diagnostic items In particular for: * `VecDeque` * `String` * `Mutex` * `HashMap` * `HashSet` cc rust-lang/rust#71414 #5393 --- changelog: none
In particular for: * `VecDeque` * `String` * `Mutex` * `HashMap` * `HashSet` cc rust-lang/rust#71414 rust-lang#5393
…=matthiaskrgr Add derive_ord_xor_partial_ord lint Fix #1621 Some remarks: This PR follows the example of the analogous derive_hash_xor_partial_eq lint where possible. I initially tried using the `match_path` function to identify `Ord` implementation like the derive_hash_xor_partial_eq lint currently does, for `Hash` implementations but that didn't work. Specifically, the structs at the top level were getting paths that matched `&["$crate", "cmp", "Ord"]` instead of `&["std", "cmp", "Ord"]`. While trying to figure out what to do instead I saw the comment at the top of [clippy_lints/src/utils/paths.rs](https://github.com/rust-lang/rust-clippy/blob/f5d429cd762423901f946abd800dc2cd91366ccf/clippy_lints/src/utils/paths.rs#L5) that mentioned [this issue](#5393) and suggested to use diagnostic items instead of hardcoded paths whenever possible. I looked for a way to identify `Ord` implementations with diagnostic items, but (possibly because this was the first time I had heard of diagnostic items,) I was unable to find one. Eventually I tried using `get_trait_def_id` and comparing `DefId` values directly and that seems to work as expected. Maybe there's a better approach however? changelog: new lint: derive_ord_xor_partial_ord
…=matthiaskrgr Add derive_ord_xor_partial_ord lint Fix #1621 Some remarks: This PR follows the example of the analogous derive_hash_xor_partial_eq lint where possible. I initially tried using the `match_path` function to identify `Ord` implementation like the derive_hash_xor_partial_eq lint currently does, for `Hash` implementations but that didn't work. Specifically, the structs at the top level were getting paths that matched `&["$crate", "cmp", "Ord"]` instead of `&["std", "cmp", "Ord"]`. While trying to figure out what to do instead I saw the comment at the top of [clippy_lints/src/utils/paths.rs](https://github.com/rust-lang/rust-clippy/blob/f5d429cd762423901f946abd800dc2cd91366ccf/clippy_lints/src/utils/paths.rs#L5) that mentioned [this issue](#5393) and suggested to use diagnostic items instead of hardcoded paths whenever possible. I looked for a way to identify `Ord` implementations with diagnostic items, but (possibly because this was the first time I had heard of diagnostic items,) I was unable to find one. Eventually I tried using `get_trait_def_id` and comparing `DefId` values directly and that seems to work as expected. Maybe there's a better approach however? changelog: new lint: derive_ord_xor_partial_ord
…ord-lint, r=matthiaskrgr Add derive_ord_xor_partial_ord lint Fix rust-lang#1621 Some remarks: This PR follows the example of the analogous derive_hash_xor_partial_eq lint where possible. I initially tried using the `match_path` function to identify `Ord` implementation like the derive_hash_xor_partial_eq lint currently does, for `Hash` implementations but that didn't work. Specifically, the structs at the top level were getting paths that matched `&["$crate", "cmp", "Ord"]` instead of `&["std", "cmp", "Ord"]`. While trying to figure out what to do instead I saw the comment at the top of [clippy_lints/src/utils/paths.rs](https://github.com/rust-lang/rust-clippy/blob/f5d429cd762423901f946abd800dc2cd91366ccf/clippy_lints/src/utils/paths.rs#L5) that mentioned [this issue](rust-lang#5393) and suggested to use diagnostic items instead of hardcoded paths whenever possible. I looked for a way to identify `Ord` implementations with diagnostic items, but (possibly because this was the first time I had heard of diagnostic items,) I was unable to find one. Eventually I tried using `get_trait_def_id` and comparing `DefId` values directly and that seems to work as expected. Maybe there's a better approach however? changelog: new lint: derive_ord_xor_partial_ord
…ord-lint, r=matthiaskrgr Add derive_ord_xor_partial_ord lint Fix rust-lang#1621 Some remarks: This PR follows the example of the analogous derive_hash_xor_partial_eq lint where possible. I initially tried using the `match_path` function to identify `Ord` implementation like the derive_hash_xor_partial_eq lint currently does, for `Hash` implementations but that didn't work. Specifically, the structs at the top level were getting paths that matched `&["$crate", "cmp", "Ord"]` instead of `&["std", "cmp", "Ord"]`. While trying to figure out what to do instead I saw the comment at the top of [clippy_lints/src/utils/paths.rs](https://github.com/rust-lang/rust-clippy/blob/f5d429cd762423901f946abd800dc2cd91366ccf/clippy_lints/src/utils/paths.rs#L5) that mentioned [this issue](rust-lang#5393) and suggested to use diagnostic items instead of hardcoded paths whenever possible. I looked for a way to identify `Ord` implementations with diagnostic items, but (possibly because this was the first time I had heard of diagnostic items,) I was unable to find one. Eventually I tried using `get_trait_def_id` and comparing `DefId` values directly and that seems to work as expected. Maybe there's a better approach however? changelog: new lint: derive_ord_xor_partial_ord
Could we use lang_items if possible ? For example: begin_panic has lang_items but no diagnostic item. |
If there is a |
migrate paths to newly-added diagnostic items This gets rid of the following paths: * OS_STRING * TO_OWNED * TO_STRING Removes some usages of: * PATH_BUF Per #5393 also removes unneeded `is_ty_param_path` from `clippy_lints::types` and relocates `is_ty_param_lang_item` and `is_ty_param_diagnostic_item` to `clippy_utils`. changelog: none
… r=compiler-errors Add diagnostic item for `std::iter::Enumerate` This adds a diagnostic item for `std::iter::Enumerate`. The change will be used by the clippy `unused_enumerate_index` lint to move away from type paths to using diagnostic items. see: rust-lang/rust-clippy#5393
… r=compiler-errors Add diagnostic item for `std::iter::Enumerate` This adds a diagnostic item for `std::iter::Enumerate`. The change will be used by the clippy `unused_enumerate_index` lint to move away from type paths to using diagnostic items. see: rust-lang/rust-clippy#5393
… r=compiler-errors Add diagnostic item for `std::iter::Enumerate` This adds a diagnostic item for `std::iter::Enumerate`. The change will be used by the clippy `unused_enumerate_index` lint to move away from type paths to using diagnostic items. see: rust-lang/rust-clippy#5393
Rollup merge of rust-lang#124308 - CBSpeir:diagnostic-item-enumerate, r=compiler-errors Add diagnostic item for `std::iter::Enumerate` This adds a diagnostic item for `std::iter::Enumerate`. The change will be used by the clippy `unused_enumerate_index` lint to move away from type paths to using diagnostic items. see: rust-lang/rust-clippy#5393
…er-errors Add diagnostic item for `std::iter::Enumerate` This adds a diagnostic item for `std::iter::Enumerate`. The change will be used by the clippy `unused_enumerate_index` lint to move away from type paths to using diagnostic items. see: rust-lang/rust-clippy#5393
…method, r=scottmcm Add diagnostic item for `std::iter::Iterator::enumerate` Adds a diagnostic item for the `std::iter:Iterator::enumerate` trait method. This change, along with PR rust-lang#124308, will be used by the clippy `unused_enumerate_index` lint to move away from paths to using diagnostic items. see: rust-lang/rust-clippy#5393
…method, r=scottmcm Add diagnostic item for `std::iter::Iterator::enumerate` Adds a diagnostic item for the `std::iter:Iterator::enumerate` trait method. This change, along with PR rust-lang#124308, will be used by the clippy `unused_enumerate_index` lint to move away from paths to using diagnostic items. see: rust-lang/rust-clippy#5393
Rollup merge of rust-lang#124542 - CBSpeir:diagnostic-item-enumerate-method, r=scottmcm Add diagnostic item for `std::iter::Iterator::enumerate` Adds a diagnostic item for the `std::iter:Iterator::enumerate` trait method. This change, along with PR rust-lang#124308, will be used by the clippy `unused_enumerate_index` lint to move away from paths to using diagnostic items. see: rust-lang/rust-clippy#5393
Remove `dead_code` paths The following paths are `dead_code` and can be removed: ### `clippy_utils::paths::VEC_RESIZE` * Introduced when `vec_resize_to_zero` lint added in PR #5637 * No longer used after commit 8acc4d2 ### `clippy_utils::paths::SLICE_GET` * Introduced when `get_first` lint added in PR #8882 * No longer used after commit a8d80d5 ### `clippy_utils::paths::STR_BYTES` * Introduced when `bytes_count_to_len` lint added in PR #8711 * No longer used after commit ba6a459 When the lints were moved into the `Methods` lint pass, they switched from using paths to diagnostic items. However, the paths were never removed. This occurred in PR #8957. This relates to issue #5393 changelog: none
…hs, r=compiler-errors [Clippy] Swap `manual_retain` to use diagnostic items instead of paths Part of rust-lang/rust-clippy#5393, just a chore.
…hs, r=compiler-errors [Clippy] Swap `manual_retain` to use diagnostic items instead of paths Part of rust-lang/rust-clippy#5393, just a chore.
Rollup merge of rust-lang#130522 - GnomedDev:clippy-manual-retain-paths, r=compiler-errors [Clippy] Swap `manual_retain` to use diagnostic items instead of paths Part of rust-lang/rust-clippy#5393, just a chore.
…ompiler-errors [Clippy] Get rid of most `std` `match_def_path` usage, swap to diagnostic items. Part of rust-lang/rust-clippy#5393. This was going to remove all `std` paths, but `SeekFrom` has issues being cleanly replaced with a diagnostic item as the paths are for variants, which currently cannot be diagnostic items. This also, as a last step, categories the paths to help with future path removals.
Rollup merge of rust-lang#130553 - GnomedDev:remove-clippy-paths, r=compiler-errors [Clippy] Get rid of most `std` `match_def_path` usage, swap to diagnostic items. Part of rust-lang/rust-clippy#5393. This was going to remove all `std` paths, but `SeekFrom` has issues being cleanly replaced with a diagnostic item as the paths are for variants, which currently cannot be diagnostic items. This also, as a last step, categories the paths to help with future path removals.
Just commenting here that the issue description links the old path to Comparing: |
Good catch, I've updated the description. Thank you! |
…=compiler-errors add last std diagnostic items for clippy Part of rust-lang/rust-clippy#5393. Add diagnostic item attributes to the items in `std` and `core` where clippy currently uses hardcoded paths (https://github.com/rust-lang/rust-clippy/blob/master/clippy_utils/src/paths.rs).
…=compiler-errors add last std diagnostic items for clippy Part of rust-lang/rust-clippy#5393. Add diagnostic item attributes to the items in `std` and `core` where clippy currently uses hardcoded paths (https://github.com/rust-lang/rust-clippy/blob/master/clippy_utils/src/paths.rs).
Rollup merge of rust-lang#137214 - cyrgani:clippy_diagnostic_items, r=compiler-errors add last std diagnostic items for clippy Part of rust-lang/rust-clippy#5393. Add diagnostic item attributes to the items in `std` and `core` where clippy currently uses hardcoded paths (https://github.com/rust-lang/rust-clippy/blob/master/clippy_utils/src/paths.rs).
…-errors add last std diagnostic items for clippy Part of rust-lang/rust-clippy#5393. Add diagnostic item attributes to the items in `std` and `core` where clippy currently uses hardcoded paths (https://github.com/rust-lang/rust-clippy/blob/master/clippy_utils/src/paths.rs).
…=compiler-errors add last std diagnostic items for clippy Part of rust-lang/rust-clippy#5393. Add diagnostic item attributes to the items in `std` and `core` where clippy currently uses hardcoded paths (https://github.com/rust-lang/rust-clippy/blob/master/clippy_utils/src/paths.rs).
…=compiler-errors add last std diagnostic items for clippy Part of rust-lang/rust-clippy#5393. Add diagnostic item attributes to the items in `std` and `core` where clippy currently uses hardcoded paths (https://github.com/rust-lang/rust-clippy/blob/master/clippy_utils/src/paths.rs).
Currently we have a ton of hardcoded paths for stdlib types.
Rustc has a way of tagging types for diagnostics via a "diagnostic item" API (rust-lang/rust#60966). We should go through rustc and tag most of these diagnostic items, and replace the hardcoded paths with hardcoded diagnostic item names instead. We can still keep the path framework around for rapid prototyping, but have a comment recommending people switch to diagnostic items whenever possible.
The text was updated successfully, but these errors were encountered: