Skip to content

Commit 042fbcc

Browse files
committed
Skip functions in PartialOrd
1 parent c4e803f commit 042fbcc

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

clippy_lints/src/unnecessary_wrap.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::utils::{
2-
in_macro, is_type_diagnostic_item, match_qpath, paths, return_ty, snippet, span_lint_and_then,
3-
visitors::find_all_ret_expressions,
2+
in_macro, is_type_diagnostic_item, match_path, match_qpath, paths, return_ty, snippet, span_lint_and_then,
3+
trait_ref_of_method, visitors::find_all_ret_expressions,
44
};
55
use if_chain::if_chain;
66
use rustc_errors::Applicability;
@@ -63,6 +63,14 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryWrap {
6363
span: Span,
6464
hir_id: HirId,
6565
) {
66+
if_chain! {
67+
if let Some(trait_ref) = trait_ref_of_method(cx, hir_id);
68+
if match_path(trait_ref.path, &paths::PARTIAL_ORD);
69+
then {
70+
return;
71+
}
72+
}
73+
6674
match fn_kind {
6775
FnKind::ItemFn(.., visibility, _) | FnKind::Method(.., Some(visibility), _) => {
6876
if visibility.node.is_pub() {

clippy_lints/src/utils/paths.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ pub const OS_STR_TO_OS_STRING: [&str; 5] = ["std", "ffi", "os_str", "OsStr", "to
8080
pub const PARKING_LOT_MUTEX_GUARD: [&str; 2] = ["parking_lot", "MutexGuard"];
8181
pub const PARKING_LOT_RWLOCK_READ_GUARD: [&str; 2] = ["parking_lot", "RwLockReadGuard"];
8282
pub const PARKING_LOT_RWLOCK_WRITE_GUARD: [&str; 2] = ["parking_lot", "RwLockWriteGuard"];
83+
pub const PARTIAL_ORD: [&str; 3] = ["std", "cmp", "PartialOrd"];
8384
pub const PATH: [&str; 3] = ["std", "path", "Path"];
8485
pub const PATH_BUF: [&str; 3] = ["std", "path", "PathBuf"];
8586
pub const PATH_BUF_AS_PATH: [&str; 4] = ["std", "path", "PathBuf", "as_path"];

0 commit comments

Comments
 (0)