From 21653d1d33f563f0b8f8881671894a23cc3a2a27 Mon Sep 17 00:00:00 2001 From: Luca Date: Sun, 18 Jan 2026 09:02:19 +0100 Subject: [PATCH] Made clippy lifetime allows conditional --- impl/src/expand.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/impl/src/expand.rs b/impl/src/expand.rs index 97466dd..38a7430 100644 --- a/impl/src/expand.rs +++ b/impl/src/expand.rs @@ -181,12 +181,19 @@ fn impl_struct(input: Struct) -> TokenStream { #from_function } }; + let lint_allows = if input.generics.lifetimes().next().is_some() { + quote! { + clippy::elidable_lifetime_names, + clippy::needless_lifetimes, + } + } else { + quote!() + }; Some(quote! { #[allow( deprecated, unused_qualifications, - clippy::elidable_lifetime_names, - clippy::needless_lifetimes, + #lint_allows )] #from_impl }) @@ -456,12 +463,19 @@ fn impl_enum(input: Enum) -> TokenStream { #from_function } }; + let lint_allows = if input.generics.lifetimes().next().is_some() { + quote! { + clippy::elidable_lifetime_names, + clippy::needless_lifetimes, + } + } else { + quote!() + }; Some(quote! { #[allow( deprecated, unused_qualifications, - clippy::elidable_lifetime_names, - clippy::needless_lifetimes, + #lint_allows )] #from_impl })