Skip to content

Commit 5e1ed8e

Browse files
committed
non_canonical_impls: save diagnostic name to a variable
1 parent 301a6dc commit 5e1ed8e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clippy_lints/src/non_canonical_impls.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ impl LateLintPass<'_> for NonCanonicalImpls {
134134
return;
135135
}
136136

137-
if cx.tcx.is_diagnostic_item(sym::Clone, trait_impl.def_id)
137+
let trait_name = cx.tcx.get_diagnostic_name(trait_impl.def_id);
138+
if trait_name == Some(sym::Clone)
138139
&& let Some(copy_def_id) = cx.tcx.get_diagnostic_item(sym::Copy)
139140
&& implements_trait(cx, trait_impl.self_ty(), copy_def_id, &[])
140141
{
@@ -175,7 +176,7 @@ impl LateLintPass<'_> for NonCanonicalImpls {
175176
}
176177
}
177178

178-
if cx.tcx.is_diagnostic_item(sym::PartialOrd, trait_impl.def_id)
179+
if trait_name == Some(sym::PartialOrd)
179180
&& impl_item.ident.name == sym::partial_cmp
180181
&& let Some(ord_def_id) = cx.tcx.get_diagnostic_item(sym::Ord)
181182
&& implements_trait(cx, trait_impl.self_ty(), ord_def_id, &[])

0 commit comments

Comments
 (0)