11use clippy_utils:: diagnostics:: { span_lint_and_sugg, span_lint_and_then} ;
22use clippy_utils:: ty:: implements_trait;
3- use clippy_utils:: { is_res_lang_ctor, last_path_segment, path_res, std_or_core} ;
3+ use clippy_utils:: { is_from_proc_macro , is_res_lang_ctor, last_path_segment, path_res, std_or_core} ;
44use rustc_errors:: Applicability ;
55use rustc_hir:: def_id:: LocalDefId ;
66use rustc_hir:: { Expr , ExprKind , ImplItem , ImplItemKind , LangItem , Node , UnOp } ;
7- use rustc_lint:: { LateContext , LateLintPass } ;
7+ use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
8+ use rustc_middle:: lint:: in_external_macro;
89use rustc_middle:: ty:: EarlyBinder ;
910use rustc_session:: declare_lint_pass;
1011use rustc_span:: sym;
@@ -111,7 +112,7 @@ declare_lint_pass!(NonCanonicalImpls => [NON_CANONICAL_CLONE_IMPL, NON_CANONICAL
111112
112113impl LateLintPass < ' _ > for NonCanonicalImpls {
113114 #[ expect( clippy:: too_many_lines) ]
114- fn check_impl_item ( & mut self , cx : & LateContext < ' _ > , impl_item : & ImplItem < ' _ > ) {
115+ fn check_impl_item < ' tcx > ( & mut self , cx : & LateContext < ' tcx > , impl_item : & ImplItem < ' tcx > ) {
115116 let Node :: Item ( item) = cx. tcx . parent_hir_node ( impl_item. hir_id ( ) ) else {
116117 return ;
117118 } ;
@@ -128,9 +129,7 @@ impl LateLintPass<'_> for NonCanonicalImpls {
128129 let ExprKind :: Block ( block, ..) = body. value . kind else {
129130 return ;
130131 } ;
131- if let Some ( expr) = block. expr
132- && expr. span . from_expansion ( )
133- {
132+ if in_external_macro ( cx. sess ( ) , block. span ) || is_from_proc_macro ( cx, impl_item) {
134133 return ;
135134 }
136135
0 commit comments