1
1
use clippy_utils:: diagnostics:: { span_lint_and_sugg, span_lint_and_then} ;
2
2
use 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} ;
4
4
use rustc_errors:: Applicability ;
5
5
use rustc_hir:: def_id:: LocalDefId ;
6
6
use 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;
8
9
use rustc_middle:: ty:: EarlyBinder ;
9
10
use rustc_session:: declare_lint_pass;
10
11
use rustc_span:: sym;
@@ -111,7 +112,7 @@ declare_lint_pass!(NonCanonicalImpls => [NON_CANONICAL_CLONE_IMPL, NON_CANONICAL
111
112
112
113
impl LateLintPass < ' _ > for NonCanonicalImpls {
113
114
#[ 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 > ) {
115
116
let Node :: Item ( item) = cx. tcx . parent_hir_node ( impl_item. hir_id ( ) ) else {
116
117
return ;
117
118
} ;
@@ -128,9 +129,7 @@ impl LateLintPass<'_> for NonCanonicalImpls {
128
129
let ExprKind :: Block ( block, ..) = body. value . kind else {
129
130
return ;
130
131
} ;
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) {
134
133
return ;
135
134
}
136
135
0 commit comments