|
1 | 1 | use clippy_utils::diagnostics::span_lint_and_sugg; |
| 2 | +use clippy_utils::is_default_equivalent; |
2 | 3 | use clippy_utils::macros::macro_backtrace; |
| 4 | +use clippy_utils::res::{MaybeDef, MaybeResPath}; |
3 | 5 | use clippy_utils::ty::expr_sig; |
4 | | -use clippy_utils::{is_default_equivalent, path_def_id}; |
5 | 6 | use rustc_errors::Applicability; |
6 | 7 | use rustc_hir::def::Res; |
7 | 8 | use rustc_hir::intravisit::{InferKind, Visitor, VisitorExt, walk_ty}; |
8 | | -use rustc_hir::{AmbigArg, Block, Expr, ExprKind, HirId, LetStmt, Node, QPath, Ty, TyKind}; |
| 9 | +use rustc_hir::{AmbigArg, Block, Expr, ExprKind, HirId, LangItem, LetStmt, Node, QPath, Ty, TyKind}; |
9 | 10 | use rustc_lint::{LateContext, LateLintPass, LintContext}; |
10 | 11 | use rustc_session::declare_lint_pass; |
11 | 12 | use rustc_span::{Span, sym}; |
@@ -44,7 +45,7 @@ impl LateLintPass<'_> for BoxDefault { |
44 | 45 | // And that method is `new` |
45 | 46 | && seg.ident.name == sym::new |
46 | 47 | // And the call is that of a `Box` method |
47 | | - && path_def_id(cx, ty).is_some_and(|id| Some(id) == cx.tcx.lang_items().owned_box()) |
| 48 | + && ty.basic_res().is_lang_item(cx, LangItem::OwnedBox) |
48 | 49 | // And the single argument to the call is another function call |
49 | 50 | // This is the `T::default()` (or default equivalent) of `Box::new(T::default())` |
50 | 51 | && let ExprKind::Call(arg_path, _) = arg.kind |
|
0 commit comments