|
1 | 1 | use clippy_utils::diagnostics::span_lint_and_then; |
2 | | -use clippy_utils::{get_trait_def_id, path_res, ty::implements_trait}; |
| 2 | +use clippy_utils::{get_trait_def_id, match_qpath, path_res, ty::implements_trait}; |
3 | 3 | use rustc_errors::Applicability; |
4 | 4 | use rustc_hir::def::Res; |
5 | 5 | 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 |
96 | 96 | if_chain! { |
97 | 97 | if block.stmts.is_empty(); |
98 | 98 | if let Some(expr) = block.expr; |
99 | | - if let ExprKind::Call(Expr { kind: ExprKind::Path(path), ..}, [cmp_expr]) = expr.kind; |
100 | | - if let QPath::Resolved(_, some_path) = path; |
101 | | - if let Some(some_seg_one) = some_path.segments.get(0); |
102 | | - if some_seg_one.ident.name == sym::Some; |
| 99 | + if let ExprKind::Call(Expr { kind: ExprKind::Path(some_path), ..}, [cmp_expr]) = expr.kind; |
| 100 | + if match_qpath(some_path, &["Some"]); |
103 | 101 | if let ExprKind::MethodCall(cmp_path, _, [other_expr], ..) = cmp_expr.kind; |
104 | 102 | if cmp_path.ident.name == sym::cmp; |
105 | 103 | if let Res::Local(..) = path_res(cx, other_expr); |
|
0 commit comments