|
1 | 1 | use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg, span_lint_and_then};
|
2 |
| -use clippy_utils::res::{MaybeDef, MaybeResPath, MaybeTypeckRes}; |
| 2 | +use clippy_utils::res::{MaybeDef, MaybeQPath, MaybeResPath, MaybeTypeckRes}; |
3 | 3 | use clippy_utils::source::{snippet, snippet_with_context};
|
4 | 4 | use clippy_utils::sugg::{DiagExt as _, Sugg};
|
5 | 5 | use clippy_utils::ty::{is_copy, same_type_modulo_regions};
|
6 |
| -use clippy_utils::{get_parent_expr, is_trait_item, is_ty_alias, sym}; |
| 6 | +use clippy_utils::{get_parent_expr, is_ty_alias, sym}; |
7 | 7 | use rustc_errors::Applicability;
|
8 | 8 | use rustc_hir::def_id::DefId;
|
9 | 9 | use rustc_hir::{BindingMode, Expr, ExprKind, HirId, MatchSource, Mutability, Node, PatKind};
|
@@ -180,7 +180,10 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
|
180 | 180 | path.ident.name,
|
181 | 181 | sym::map | sym::map_err | sym::map_break | sym::map_continue
|
182 | 182 | ) && has_eligible_receiver(cx, recv, e)
|
183 |
| - && (is_trait_item(cx, arg, sym::Into) || is_trait_item(cx, arg, sym::From)) |
| 183 | + && matches!( |
| 184 | + arg.res(cx).assoc_parent(cx).opt_diag_name(cx), |
| 185 | + Some(sym::Into | sym::From) |
| 186 | + ) |
184 | 187 | && let ty::FnDef(_, args) = cx.typeck_results().expr_ty(arg).kind()
|
185 | 188 | && let &[from_ty, to_ty] = args.into_type_list(cx.tcx).as_slice()
|
186 | 189 | && same_type_modulo_regions(from_ty, to_ty)
|
|
0 commit comments