diff options
| author | Ryan1729 <Ryan1729@gmail.com> | 2020-07-26 23:04:04 -0600 |
|---|---|---|
| committer | Ryan1729 <Ryan1729@gmail.com> | 2020-07-26 23:04:04 -0600 |
| commit | a8d6eda93049f0077c1515bec35fe0359ea43f96 (patch) | |
| tree | f881e3eeafb81c7e76c22b4f85dc85e1f322f6e6 | |
| parent | 068acbd27b19a4a7be3a9d00954ecfad8a0e6553 (diff) | |
| download | rust-a8d6eda93049f0077c1515bec35fe0359ea43f96.tar.gz rust-a8d6eda93049f0077c1515bec35fe0359ea43f96.zip | |
use get_trait_def_id to check for Ord trait
| -rw-r--r-- | clippy_lints/src/derive.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index 4f69c2d7af7..04395621e9e 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -1,6 +1,6 @@ use crate::utils::paths; use crate::utils::{ - is_automatically_derived, is_copy, match_path, span_lint_and_help, span_lint_and_note, span_lint_and_then, + get_trait_def_id, is_automatically_derived, is_copy, match_path, span_lint_and_help, span_lint_and_note, span_lint_and_then, }; use if_chain::if_chain; use rustc_hir::def_id::DefId; @@ -211,9 +211,10 @@ fn check_ord_pord<'tcx>( ord_is_automatically_derived: bool, ) { if_chain! { - if match_path(&trait_ref.path, &paths::ORD); + if let Some(ord_trait_def_id) = get_trait_def_id(cx, &paths::ORD); if let Some(pord_trait_def_id) = cx.tcx.lang_items().partial_ord_trait(); if let Some(def_id) = &trait_ref.trait_def_id(); + if *def_id == ord_trait_def_id; if !def_id.is_local(); then { // Look for the PartialOrd implementations for `ty` |
