Skip to content

Commit

Permalink
Add #[automatically_derived] to derived impls (#8080)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser authored Oct 20, 2023
1 parent 256b98a commit a525f09
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/ruff_macros/src/cache_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ pub(crate) fn derive_cache_key(item: &DeriveInput) -> syn::Result<TokenStream> {
let (impl_generics, ty_generics, where_clause) = &item.generics.split_for_impl();

Ok(quote!(
#[automatically_derived]
impl #impl_generics ruff_cache::CacheKey for #name #ty_generics #where_clause {
fn cache_key(&self, key: &mut ruff_cache::CacheKeyHasher) {
use std::hash::Hasher;
Expand Down
1 change: 1 addition & 0 deletions crates/ruff_macros/src/combine_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub(crate) fn derive_impl(input: DeriveInput) -> syn::Result<proc_macro2::TokenS
.collect::<Result<Vec<_>, _>>()?;

Ok(quote! {
#[automatically_derived]
impl crate::configuration::CombinePluginOptions for #ident {
fn combine(self, other: Self) -> Self {
#[allow(deprecated)]
Expand Down
1 change: 1 addition & 0 deletions crates/ruff_macros/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ pub(crate) fn derive_impl(input: DeriveInput) -> syn::Result<TokenStream> {
};

Ok(quote! {
#[automatically_derived]
impl crate::options_base::OptionsMetadata for #ident {
fn record(visit: &mut dyn crate::options_base::Visit) {
#(#output);*
Expand Down
1 change: 1 addition & 0 deletions crates/ruff_macros/src/rule_namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ pub(crate) fn derive_impl(input: DeriveInput) -> syn::Result<proc_macro2::TokenS
}

Ok(quote! {
#[automatically_derived]
impl crate::registry::RuleNamespace for #ident {
fn parse_code(code: &str) -> Option<(Self, &str)> {
#if_statements
Expand Down
2 changes: 2 additions & 0 deletions crates/ruff_macros/src/violation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub(crate) fn violation(violation: &ItemStruct) -> Result<TokenStream> {
#[derive(Debug, PartialEq, Eq)]
#violation

#[automatically_derived]
impl From<#ident> for ruff_diagnostics::DiagnosticKind {
fn from(value: #ident) -> Self {
use ruff_diagnostics::Violation;
Expand All @@ -76,6 +77,7 @@ pub(crate) fn violation(violation: &ItemStruct) -> Result<TokenStream> {
}
}

#[automatically_derived]
impl From<#ident> for ruff_diagnostics::DiagnosticKind {
fn from(value: #ident) -> Self {
use ruff_diagnostics::Violation;
Expand Down

0 comments on commit a525f09

Please sign in to comment.