Skip to content

Commit 299ff49

Browse files
authored
Rollup merge of rust-lang#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: rust-lang/rust-clippy#6620 (comment)
2 parents 7bd3d6c + 8c00304 commit 299ff49

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

clippy_lints/src/fallible_impl_from.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use crate::utils::paths::FROM_TRAIT;
2-
use crate::utils::{
3-
is_expn_of, is_type_diagnostic_item, match_def_path, match_panic_def_id, method_chain_args, span_lint_and_then,
4-
};
1+
use crate::utils::{is_expn_of, is_type_diagnostic_item, match_panic_def_id, method_chain_args, span_lint_and_then};
52
use if_chain::if_chain;
63
use rustc_hir as hir;
74
use rustc_lint::{LateContext, LateLintPass};
@@ -59,7 +56,7 @@ impl<'tcx> LateLintPass<'tcx> for FallibleImplFrom {
5956
if_chain! {
6057
if let hir::ItemKind::Impl(impl_) = &item.kind;
6158
if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(impl_def_id);
62-
if match_def_path(cx, impl_trait_ref.def_id, &FROM_TRAIT);
59+
if cx.tcx.is_diagnostic_item(sym::from_trait, impl_trait_ref.def_id);
6360
then {
6461
lint_impl_body(cx, item.span, impl_.items);
6562
}

clippy_lints/src/utils/paths.rs

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ pub const FN_MUT: [&str; 3] = ["core", "ops", "FnMut"];
4848
pub const FN_ONCE: [&str; 3] = ["core", "ops", "FnOnce"];
4949
pub const FROM_FROM: [&str; 4] = ["core", "convert", "From", "from"];
5050
pub const FROM_ITERATOR: [&str; 5] = ["core", "iter", "traits", "collect", "FromIterator"];
51-
pub const FROM_TRAIT: [&str; 3] = ["core", "convert", "From"];
5251
pub const FUTURE_FROM_GENERATOR: [&str; 3] = ["core", "future", "from_generator"];
5352
pub const HASH: [&str; 3] = ["core", "hash", "Hash"];
5453
pub const HASHMAP: [&str; 5] = ["std", "collections", "hash", "map", "HashMap"];

0 commit comments

Comments
 (0)