Skip to content

Commit

Permalink
Close #114: Add #[automatically_derived] to generated impls
Browse files Browse the repository at this point in the history
  • Loading branch information
idanarye committed Sep 18, 2023
1 parent 0cf6f3d commit 30bf3fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed
- Add `#[allow(clippy::exhaustive_enums)]` to generated empty enums used for
error "reporting" (see issue #112)
- Add `#[automatically_derived]` to generated `impl`s (see issue #114)

## 0.16.0 - 2023-08-26
### Added
Expand Down
6 changes: 6 additions & 0 deletions typed-builder-macro/src/struct_info.rs
Expand Up @@ -134,6 +134,7 @@ impl<'a> StructInfo<'a> {
}

Ok(quote! {
#[automatically_derived]
impl #impl_generics #name #ty_generics #where_clause {
#builder_method_doc
#[allow(dead_code, clippy::default_trait_access)]
Expand All @@ -153,6 +154,7 @@ impl<'a> StructInfo<'a> {
phantom: ::core::marker::PhantomData<(#( #phantom_generics ),*)>,
}

#[automatically_derived]
impl #b_generics_impl Clone for #builder_name #b_generics_ty #b_generics_where {
#[allow(clippy::default_trait_access)]
fn clone(&self) -> Self {
Expand Down Expand Up @@ -266,6 +268,7 @@ impl<'a> StructInfo<'a> {

Ok(quote! {
#[allow(dead_code, non_camel_case_types, missing_docs)]
#[automatically_derived]
impl #impl_generics #builder_name < #( #ty_generics ),* > #where_clause {
#deprecated
#doc
Expand All @@ -284,6 +287,7 @@ impl<'a> StructInfo<'a> {
pub enum #repeated_fields_error_type_name {}
#[doc(hidden)]
#[allow(dead_code, non_camel_case_types, missing_docs)]
#[automatically_derived]
impl #impl_generics #builder_name < #( #target_generics ),* > #where_clause {
#[deprecated(
note = #repeated_fields_error_message
Expand Down Expand Up @@ -373,6 +377,7 @@ impl<'a> StructInfo<'a> {
pub enum #early_build_error_type_name {}
#[doc(hidden)]
#[allow(dead_code, non_camel_case_types, missing_docs, clippy::panic)]
#[automatically_derived]
impl #impl_generics #builder_name < #( #builder_generics ),* > #where_clause {
#[deprecated(
note = #early_build_error_message
Expand Down Expand Up @@ -489,6 +494,7 @@ impl<'a> StructInfo<'a> {

quote!(
#[allow(dead_code, non_camel_case_types, missing_docs)]
#[automatically_derived]
impl #impl_generics #builder_name #modified_ty_generics #where_clause {
#build_method_doc
#[allow(clippy::default_trait_access)]
Expand Down

0 comments on commit 30bf3fa

Please sign in to comment.