From aa19b7cfce13336cb171ad6e8cdb9b50cc1c9dd5 Mon Sep 17 00:00:00 2001 From: Matthew Donoughe Date: Tue, 3 Dec 2024 08:40:10 -0500 Subject: [PATCH] suppress needless_lifetimes lints from clippy 0.1.83 --- impl/src/expand.rs | 4 ++-- tests/test_lints.rs | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/impl/src/expand.rs b/impl/src/expand.rs index e172af97..23e77b65 100644 --- a/impl/src/expand.rs +++ b/impl/src/expand.rs @@ -197,7 +197,7 @@ fn impl_struct(input: Struct) -> TokenStream { let source_var = Ident::new("source", span); let body = from_initializer(from_field, backtrace_field, &source_var); quote_spanned! {span=> - #[allow(unused_qualifications)] + #[allow(unused_qualifications, clippy::needless_lifetimes)] #[automatically_derived] impl #impl_generics ::core::convert::From<#from> for #ty #ty_generics #where_clause { #[allow(deprecated)] @@ -462,7 +462,7 @@ fn impl_enum(input: Enum) -> TokenStream { let source_var = Ident::new("source", span); let body = from_initializer(from_field, backtrace_field, &source_var); Some(quote_spanned! {span=> - #[allow(unused_qualifications)] + #[allow(unused_qualifications, clippy::needless_lifetimes)] #[automatically_derived] impl #impl_generics ::core::convert::From<#from> for #ty #ty_generics #where_clause { #[allow(deprecated)] diff --git a/tests/test_lints.rs b/tests/test_lints.rs index cafcbc0f..1473682e 100644 --- a/tests/test_lints.rs +++ b/tests/test_lints.rs @@ -18,3 +18,18 @@ fn test_unused_qualifications() { let _: MyError; } + +#[test] +fn test_needless_lifetimes() { + #![allow(dead_code)] + #![deny(clippy::needless_lifetimes)] + + #[derive(Debug, Error)] + #[error("...")] + pub enum MyError<'a> { + A(#[from] std::io::Error), + B(&'a ()), + } + + let _: MyError; +}