Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions impl/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,18 @@ fn impl_struct(input: Struct) -> TokenStream {
let from = unoptional_type(from_field.ty);
let source_var = Ident::new("source", span);
let body = from_initializer(from_field, backtrace_field, &source_var);
quote_spanned! {span=>
#[allow(deprecated, unused_qualifications, clippy::needless_lifetimes)]
let impl_impl = quote_spanned! {span=>
#[automatically_derived]
impl #impl_generics ::core::convert::From<#from> for #ty #ty_generics #where_clause {
fn from(#source_var: #from) -> Self {
#ty #body
}
}
}
};
Some(quote! {
#[allow(deprecated, unused_qualifications, clippy::needless_lifetimes)]
#impl_impl
})
});

if input.generics.type_params().next().is_some() {
Expand Down Expand Up @@ -433,14 +436,17 @@ fn impl_enum(input: Enum) -> TokenStream {
let from = unoptional_type(from_field.ty);
let source_var = Ident::new("source", span);
let body = from_initializer(from_field, backtrace_field, &source_var);
Some(quote_spanned! {span=>
#[allow(deprecated, unused_qualifications, clippy::needless_lifetimes)]
let impl_impl = quote_spanned! {span=>
#[automatically_derived]
impl #impl_generics ::core::convert::From<#from> for #ty #ty_generics #where_clause {
fn from(#source_var: #from) -> Self {
#ty::#variant #body
}
}
};
Some(quote! {
#[allow(deprecated, unused_qualifications, clippy::needless_lifetimes)]
#impl_impl
})
});

Expand Down
11 changes: 11 additions & 0 deletions tests/test_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ use thiserror::Error;

pub use std::error::Error;

#[test]
fn test_allow_attributes() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test doesn't actually do anything. For some reason #![deny(clippy::allow_attributes)] never works here with any lint - it's as if it's not set. Nor does passing -Dclippy::allow_attributes. Maybe something about being a test target for the crate itself? I don't know

#![deny(clippy::allow_attributes)]

#[derive(Error, Debug)]
#[error("...")]
pub struct MyError(#[from] anyhow::Error);

let _: MyError;
}

#[test]
fn test_unused_qualifications() {
#![deny(unused_qualifications)]
Expand Down
Loading