@@ -2,10 +2,9 @@ use clippy_utils::diagnostics::span_lint_and_help;
2
2
use clippy_utils:: { in_macro, is_automatically_derived, is_default_equivalent, remove_blocks} ;
3
3
use rustc_hir:: {
4
4
def:: { DefKind , Res } ,
5
- Body , Expr , ExprKind , Impl , ImplItemKind , Item , ItemKind , Node , QPath ,
5
+ Body , Expr , ExprKind , GenericArg , Impl , ImplItemKind , Item , ItemKind , Node , PathSegment , QPath , TyKind ,
6
6
} ;
7
7
use rustc_lint:: { LateContext , LateLintPass } ;
8
- use rustc_middle:: ty:: TypeFoldable ;
9
8
use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
10
9
use rustc_span:: sym;
11
10
@@ -68,6 +67,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
68
67
if let ItemKind :: Impl ( Impl {
69
68
of_trait: Some ( ref trait_ref) ,
70
69
items: [ child] ,
70
+ self_ty,
71
71
..
72
72
} ) = item. kind;
73
73
if let attrs = cx. tcx. hir( ) . attrs( item. hir_id( ) ) ;
@@ -80,9 +80,18 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
80
80
if let ImplItemKind :: Fn ( _, b) = & impl_item. kind;
81
81
if let Body { value: func_expr, .. } = cx. tcx. hir( ) . body( * b) ;
82
82
if let Some ( adt_def) = cx. tcx. type_of( item. def_id) . ty_adt_def( ) ;
83
+ if !attrs. iter( ) . any( |attr| attr. doc_str( ) . is_some( ) ) ;
84
+ if let child_attrs = cx. tcx. hir( ) . attrs( impl_item_hir) ;
85
+ if !child_attrs. iter( ) . any( |attr| attr. doc_str( ) . is_some( ) ) ;
83
86
then {
84
- if cx. tcx. type_of( item. def_id) . definitely_has_param_types_or_consts( cx. tcx) {
85
- return ;
87
+ if let TyKind :: Path ( QPath :: Resolved ( _, p) ) = self_ty. kind {
88
+ if let Some ( PathSegment { args: Some ( a) , .. } ) = p. segments. last( ) {
89
+ for arg in a. args {
90
+ if !matches!( arg, GenericArg :: Lifetime ( _) ) {
91
+ return ;
92
+ }
93
+ }
94
+ }
86
95
}
87
96
let should_emit = match remove_blocks( func_expr) . kind {
88
97
ExprKind :: Tup ( fields) => fields. iter( ) . all( |e| is_default_equivalent( cx, e) ) ,
0 commit comments