|
1 | 1 | use clippy_utils::diagnostics::span_lint_and_then;
|
2 | 2 | use clippy_utils::source::snippet;
|
3 |
| -use clippy_utils::{match_def_path, paths, SpanlessEq}; |
| 3 | +use clippy_utils::SpanlessEq; |
4 | 4 | use rustc_errors::Applicability;
|
5 | 5 | use rustc_hir::{Expr, ExprKind, Pat, Stmt, StmtKind, UnOp};
|
6 | 6 | use rustc_lint::LateContext;
|
7 |
| -use rustc_span::Span; |
| 7 | +use rustc_span::{sym, Symbol, Span}; |
8 | 8 | use std::borrow::Cow;
|
9 | 9 |
|
10 | 10 | use super::MANUAL_WHILE_LET_SOME;
|
@@ -47,20 +47,20 @@ fn report_lint(cx: &LateContext<'_>, pop_span: Span, pop_stmt_kind: PopStmt<'_>,
|
47 | 47 | );
|
48 | 48 | }
|
49 | 49 |
|
50 |
| -fn match_method_call(cx: &LateContext<'_>, expr: &Expr<'_>, method: &[&str]) -> bool { |
| 50 | +fn match_method_call(cx: &LateContext<'_>, expr: &Expr<'_>, method: Symbol) -> bool { |
51 | 51 | if let ExprKind::MethodCall(..) = expr.kind
|
52 | 52 | && let Some(id) = cx.typeck_results().type_dependent_def_id(expr.hir_id)
|
53 | 53 | {
|
54 |
| - match_def_path(cx, id, method) |
| 54 | + cx.tcx.is_diagnostic_item(method, id) |
55 | 55 | } else {
|
56 | 56 | false
|
57 | 57 | }
|
58 | 58 | }
|
59 | 59 |
|
60 | 60 | fn is_vec_pop_unwrap(cx: &LateContext<'_>, expr: &Expr<'_>, is_empty_recv: &Expr<'_>) -> bool {
|
61 |
| - if (match_method_call(cx, expr, &paths::OPTION_UNWRAP) || match_method_call(cx, expr, &paths::OPTION_EXPECT)) |
| 61 | + if (match_method_call(cx, expr, sym::option_unwrap) || match_method_call(cx, expr, sym::option_expect)) |
62 | 62 | && let ExprKind::MethodCall(_, unwrap_recv, ..) = expr.kind
|
63 |
| - && match_method_call(cx, unwrap_recv, &paths::VEC_POP) |
| 63 | + && match_method_call(cx, unwrap_recv, sym::vec_pop) |
64 | 64 | && let ExprKind::MethodCall(_, pop_recv, ..) = unwrap_recv.kind
|
65 | 65 | {
|
66 | 66 | // make sure they're the same `Vec`
|
@@ -96,7 +96,7 @@ fn check_call_arguments(cx: &LateContext<'_>, stmt: &Stmt<'_>, is_empty_recv: &E
|
96 | 96 | pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, full_cond: &'tcx Expr<'_>, body: &'tcx Expr<'_>, loop_span: Span) {
|
97 | 97 | if let ExprKind::Unary(UnOp::Not, cond) = full_cond.kind
|
98 | 98 | && let ExprKind::MethodCall(_, is_empty_recv, _, _) = cond.kind
|
99 |
| - && match_method_call(cx, cond, &paths::VEC_IS_EMPTY) |
| 99 | + && match_method_call(cx, cond, sym::vec_is_empty) |
100 | 100 | && let ExprKind::Block(body, _) = body.kind
|
101 | 101 | && let Some(stmt) = body.stmts.first()
|
102 | 102 | {
|
|
0 commit comments