@@ -2,10 +2,9 @@ use clippy_utils::diagnostics::span_lint_and_help;
22use clippy_utils:: { in_macro, is_automatically_derived, is_default_equivalent, remove_blocks} ;
33use rustc_hir:: {
44 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 ,
66} ;
77use rustc_lint:: { LateContext , LateLintPass } ;
8- use rustc_middle:: ty:: TypeFoldable ;
98use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
109use rustc_span:: sym;
1110
@@ -68,6 +67,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
6867 if let ItemKind :: Impl ( Impl {
6968 of_trait: Some ( ref trait_ref) ,
7069 items: [ child] ,
70+ self_ty,
7171 ..
7272 } ) = item. kind;
7373 if let attrs = cx. tcx. hir( ) . attrs( item. hir_id( ) ) ;
@@ -80,9 +80,18 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
8080 if let ImplItemKind :: Fn ( _, b) = & impl_item. kind;
8181 if let Body { value: func_expr, .. } = cx. tcx. hir( ) . body( * b) ;
8282 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( ) ) ;
8386 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+ }
8695 }
8796 let should_emit = match remove_blocks( func_expr) . kind {
8897 ExprKind :: Tup ( fields) => fields. iter( ) . all( |e| is_default_equivalent( cx, e) ) ,
0 commit comments