Skip to content

Replace allowing specific lints for derived impls with #[automatically_derived] #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions src/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn derive_copy(input: &ast::Input) -> proc_macro2::TokenStream {
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();

quote! {
#[allow(unused_qualifications)]
#[automatically_derived]
impl #impl_generics #copy_trait_path for #name #ty_generics #where_clause {}
}
}
Expand All @@ -43,7 +43,7 @@ pub fn derive_clone(input: &ast::Input) -> proc_macro2::TokenStream {
let is_copy = input.attrs.copy.is_some();
if is_copy && input.generics.type_params().count() == 0 {
quote! {
#[allow(unused_qualifications)]
#[automatically_derived]
impl #impl_generics #clone_trait_path for #name #ty_generics #where_clause {
fn clone(&self) -> Self {
*self
Expand Down Expand Up @@ -159,7 +159,7 @@ pub fn derive_clone(input: &ast::Input) -> proc_macro2::TokenStream {
});

quote! {
#[allow(unused_qualifications)]
#[automatically_derived]
impl #impl_generics #clone_trait_path for #name #ty_generics #where_clause {
fn clone(&self) -> Self {
match *self {
Expand Down
11 changes: 4 additions & 7 deletions src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn derive_eq(input: &ast::Input) -> proc_macro2::TokenStream {
}

quote! {
#[allow(unused_qualifications)]
#[automatically_derived]
impl #impl_generics #eq_trait_path for #name #ty_generics #where_clause {}
}
}
Expand Down Expand Up @@ -95,8 +95,7 @@ pub fn derive_partial_eq(input: &ast::Input) -> proc_macro2::TokenStream {
}

quote! {
#[allow(unused_qualifications)]
#[allow(clippy::unneeded_field_pattern)]
#[automatically_derived]
impl #impl_generics #partial_eq_trait_path for #name #ty_generics #where_clause {
fn eq(&self, other: &Self) -> bool {
#discriminant_cmp && #match_fields
Expand Down Expand Up @@ -196,8 +195,7 @@ pub fn derive_partial_ord(
}

quote! {
#[allow(unused_qualifications)]
#[allow(clippy::unneeded_field_pattern)]
#[automatically_derived]
impl #impl_generics #partial_ord_trait_path for #name #ty_generics #where_clause {
fn partial_cmp(&self, other: &Self) -> #option_path<#ordering_path> {
match *self {
Expand Down Expand Up @@ -293,8 +291,7 @@ pub fn derive_ord(
}

quote! {
#[allow(unused_qualifications)]
#[allow(clippy::unneeded_field_pattern)]
#[automatically_derived]
impl #impl_generics #ord_trait_path for #name #ty_generics #where_clause {
fn cmp(&self, other: &Self) -> #ordering_path {
match *self {
Expand Down
3 changes: 1 addition & 2 deletions src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ pub fn derive(input: &ast::Input) -> proc_macro2::TokenStream {
// don't attach a span to prevent issue #58
let match_self = quote!(match *self);
quote_spanned! {input.span=>
#[allow(unused_qualifications)]
#[allow(clippy::unneeded_field_pattern)]
#[automatically_derived]
impl #impl_generics #debug_trait_path for #name #ty_generics #where_clause {
fn fmt(&self, #formatter: &mut #fmt_path::Formatter) -> #fmt_path::Result {
#match_self {
Expand Down
4 changes: 2 additions & 2 deletions src/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub fn derive(input: &ast::Input, default: &attr::InputDefault) -> proc_macro2::

let new_fn = if default.new {
Some(quote!(
#[allow(unused_qualifications)]
#[automatically_derived]
impl #impl_generics #name #ty_generics #where_clause {
/// Creates a default value for this type.
#[inline]
Expand All @@ -101,7 +101,7 @@ pub fn derive(input: &ast::Input, default: &attr::InputDefault) -> proc_macro2::
quote!(
#new_fn

#[allow(unused_qualifications)]
#[automatically_derived]
impl #impl_generics #default_trait_path for #name #ty_generics #where_clause {
fn default() -> Self {
#body
Expand Down
2 changes: 1 addition & 1 deletion src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn derive(input: &ast::Input) -> proc_macro2::TokenStream {

let hasher_ty_parameter = utils::hygienic_type_parameter(input, "__H");
quote! {
#[allow(unused_qualifications)]
#[automatically_derived]
impl #impl_generics #hash_trait_path for #name #ty_generics #where_clause {
fn hash<#hasher_ty_parameter>(&self, __state: &mut #hasher_ty_parameter)
where #hasher_ty_parameter: #hasher_trait_path
Expand Down