1
1
use clippy_utils:: diagnostics:: span_lint_and_sugg;
2
2
use clippy_utils:: ty:: same_type_and_consts;
3
- use clippy_utils:: { meets_msrv, msrvs} ;
3
+ use clippy_utils:: { is_from_proc_macro , meets_msrv, msrvs} ;
4
4
use if_chain:: if_chain;
5
5
use rustc_data_structures:: fx:: FxHashSet ;
6
6
use rustc_errors:: Applicability ;
@@ -87,7 +87,7 @@ impl_lint_pass!(UseSelf => [USE_SELF]);
87
87
const SEGMENTS_MSG : & str = "segments should be composed of at least 1 element" ;
88
88
89
89
impl < ' tcx > LateLintPass < ' tcx > for UseSelf {
90
- fn check_item ( & mut self , _cx : & LateContext < ' _ > , item : & Item < ' _ > ) {
90
+ fn check_item ( & mut self , cx : & LateContext < ' tcx > , item : & Item < ' tcx > ) {
91
91
if matches ! ( item. kind, ItemKind :: OpaqueTy ( _) ) {
92
92
// skip over `ItemKind::OpaqueTy` in order to lint `foo() -> impl <..>`
93
93
return ;
@@ -103,6 +103,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
103
103
if parameters. as_ref( ) . map_or( true , |params| {
104
104
!params. parenthesized && !params. args. iter( ) . any( |arg| matches!( arg, GenericArg :: Lifetime ( _) ) )
105
105
} ) ;
106
+ if !is_from_proc_macro( cx, item) ; // expensive, should be last check
106
107
then {
107
108
StackItem :: Check {
108
109
impl_id: item. def_id,
@@ -213,9 +214,6 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
213
214
hir_ty_to_ty( cx. tcx, hir_ty)
214
215
} ;
215
216
if same_type_and_consts( ty, cx. tcx. type_of( impl_id) ) ;
216
- let hir = cx. tcx. hir( ) ;
217
- // prevents false positive on `#[derive(serde::Deserialize)]`
218
- if !hir. span( hir. get_parent_node( hir_ty. hir_id) ) . in_derive_expansion( ) ;
219
217
then {
220
218
span_lint( cx, hir_ty. span) ;
221
219
}
0 commit comments