diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2021-01-28 15:09:08 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-28 15:09:08 +0900 |
| commit | 70be5cef699d5dcbe9457f4def66055a9ef6b966 (patch) | |
| tree | cba5a1432773caf49f64dbb34093cf2377b4cf41 /src/tools | |
| parent | 84ad95be70d3a1b06ed537e4e7ec0c8e1086cb36 (diff) | |
| parent | e25959b417fe2a08d808f9ddc737c2c9742d6d6a (diff) | |
| download | rust-70be5cef699d5dcbe9457f4def66055a9ef6b966.tar.gz rust-70be5cef699d5dcbe9457f4def66055a9ef6b966.zip | |
Rollup merge of #81277 - flip1995:from_diag_items, r=matthewjasper
Make more traits of the From/Into family diagnostic items Following traits are now diagnostic items: - `From` (unchanged) - `Into` - `TryFrom` - `TryInto` This also adds symbols for those items: - `into_trait` - `try_from_trait` - `try_into_trait` Related: https://github.com/rust-lang/rust-clippy/pull/6620#discussion_r562482587
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/clippy/clippy_lints/src/fallible_impl_from.rs | 7 | ||||
| -rw-r--r-- | src/tools/clippy/clippy_lints/src/utils/paths.rs | 1 |
2 files changed, 2 insertions, 6 deletions
diff --git a/src/tools/clippy/clippy_lints/src/fallible_impl_from.rs b/src/tools/clippy/clippy_lints/src/fallible_impl_from.rs index 9f389c8d2f9..527905e375d 100644 --- a/src/tools/clippy/clippy_lints/src/fallible_impl_from.rs +++ b/src/tools/clippy/clippy_lints/src/fallible_impl_from.rs @@ -1,7 +1,4 @@ -use crate::utils::paths::FROM_TRAIT; -use crate::utils::{ - is_expn_of, is_type_diagnostic_item, match_def_path, match_panic_def_id, method_chain_args, span_lint_and_then, -}; +use crate::utils::{is_expn_of, is_type_diagnostic_item, match_panic_def_id, method_chain_args, span_lint_and_then}; use if_chain::if_chain; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; @@ -59,7 +56,7 @@ impl<'tcx> LateLintPass<'tcx> for FallibleImplFrom { if_chain! { if let hir::ItemKind::Impl(impl_) = &item.kind; if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(impl_def_id); - if match_def_path(cx, impl_trait_ref.def_id, &FROM_TRAIT); + if cx.tcx.is_diagnostic_item(sym::from_trait, impl_trait_ref.def_id); then { lint_impl_body(cx, item.span, impl_.items); } diff --git a/src/tools/clippy/clippy_lints/src/utils/paths.rs b/src/tools/clippy/clippy_lints/src/utils/paths.rs index c0b203b5388..432cc5b59f6 100644 --- a/src/tools/clippy/clippy_lints/src/utils/paths.rs +++ b/src/tools/clippy/clippy_lints/src/utils/paths.rs @@ -48,7 +48,6 @@ pub const FN_MUT: [&str; 3] = ["core", "ops", "FnMut"]; pub const FN_ONCE: [&str; 3] = ["core", "ops", "FnOnce"]; pub const FROM_FROM: [&str; 4] = ["core", "convert", "From", "from"]; pub const FROM_ITERATOR: [&str; 5] = ["core", "iter", "traits", "collect", "FromIterator"]; -pub const FROM_TRAIT: [&str; 3] = ["core", "convert", "From"]; pub const FUTURE_FROM_GENERATOR: [&str; 3] = ["core", "future", "from_generator"]; pub const HASH: [&str; 3] = ["core", "hash", "Hash"]; pub const HASHMAP: [&str; 5] = ["std", "collections", "hash", "map", "HashMap"]; |
