From 295b517697ee6004343cf6782ae2ba179f36c257 Mon Sep 17 00:00:00 2001 From: Centri3 <114838443+Centri3@users.noreply.github.com> Date: Mon, 15 May 2023 20:28:59 -0500 Subject: [PATCH] refactor --- clippy_lints/src/manual_partial_ord_and_ord_impl.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/clippy_lints/src/manual_partial_ord_and_ord_impl.rs b/clippy_lints/src/manual_partial_ord_and_ord_impl.rs index bc61650fd3ee..8c7c7b9f7820 100644 --- a/clippy_lints/src/manual_partial_ord_and_ord_impl.rs +++ b/clippy_lints/src/manual_partial_ord_and_ord_impl.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::{get_trait_def_id, path_res, ty::implements_trait}; +use clippy_utils::{get_trait_def_id, match_qpath, path_res, ty::implements_trait}; use rustc_errors::Applicability; use rustc_hir::def::Res; use rustc_hir::{Expr, ExprKind, Impl, ImplItemKind, Item, ItemKind, PatKind, QPath}; @@ -96,10 +96,8 @@ fn lint_impl_body(conf: &mut ManualPartialOrdAndOrdImpl, cx: &LateContext<'_>, i if_chain! { if block.stmts.is_empty(); if let Some(expr) = block.expr; - if let ExprKind::Call(Expr { kind: ExprKind::Path(path), ..}, [cmp_expr]) = expr.kind; - if let QPath::Resolved(_, some_path) = path; - if let Some(some_seg_one) = some_path.segments.get(0); - if some_seg_one.ident.name == sym::Some; + if let ExprKind::Call(Expr { kind: ExprKind::Path(some_path), ..}, [cmp_expr]) = expr.kind; + if match_qpath(some_path, &["Some"]); if let ExprKind::MethodCall(cmp_path, _, [other_expr], ..) = cmp_expr.kind; if cmp_path.ident.name == sym::cmp; if let Res::Local(..) = path_res(cx, other_expr);