From c0b03c4093a8b1968610a70d1a044d5f16a188a6 Mon Sep 17 00:00:00 2001 From: "Lan, Jian" Date: Sun, 15 Feb 2026 23:46:06 +0800 Subject: [PATCH 1/2] refactor: remove automatic `Debug` derive and trait bounds from generated patch types --- patchable-macro/src/context.rs | 23 +++++++++-------------- patchable/tests/no_serde.rs | 10 ---------- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/patchable-macro/src/context.rs b/patchable-macro/src/context.rs index 3cb5ade..12f3260 100644 --- a/patchable-macro/src/context.rs +++ b/patchable-macro/src/context.rs @@ -146,9 +146,9 @@ impl<'a> MacroContext<'a> { }; let patch_name = &self.patch_struct_name; let derive_attr = if IS_SERDE_ENABLED { - quote! { #[derive(::core::fmt::Debug, ::serde::Deserialize)] } + quote! { #[derive(::serde::Deserialize)] } } else { - quote! { #[derive(::core::fmt::Debug)] } + quote! {} }; quote! { @@ -359,31 +359,26 @@ impl<'a> MacroContext<'a> { // =========================================== fn build_where_clause_with_bound(&self, bound: &TokenStream2) -> TokenStream2 { - self.build_where_clause_for_patchable_types(|ty, patchable_trait| { - quote! { - #ty: #bound, - <#ty as #patchable_trait>::Patch: ::core::fmt::Debug, - } - }) + self.build_where_clause_for_patchable_types(|ty| quote! { #ty: #bound, }) } fn build_where_clause_for_from_impl(&self) -> TokenStream2 { - self.build_where_clause_for_patchable_types(|ty, patchable_trait| { + let patchable_trait = &self.patchable_trait; + self.build_where_clause_for_patchable_types(|ty| { quote! { #ty: #patchable_trait, - <#ty as #patchable_trait>::Patch: ::core::convert::From<#ty> + ::core::fmt::Debug, + <#ty as #patchable_trait>::Patch: ::core::convert::From<#ty>, } }) } - fn build_where_clause_for_patchable_types(&self, mut build_bounds: F) -> TokenStream2 + fn build_where_clause_for_patchable_types(&self, build_bounds: F) -> TokenStream2 where - F: FnMut(&Ident, &TokenStream2) -> TokenStream2, + F: Fn(&Ident) -> TokenStream2, { - let patchable_trait = &self.patchable_trait; let bounded_types: Vec<_> = self .iter_patchable_type_params() - .map(|ty| build_bounds(ty, patchable_trait)) + .map(build_bounds) .collect(); self.extend_where_clause(bounded_types) } diff --git a/patchable/tests/no_serde.rs b/patchable/tests/no_serde.rs index 50b3bd6..a0209f3 100644 --- a/patchable/tests/no_serde.rs +++ b/patchable/tests/no_serde.rs @@ -35,21 +35,11 @@ struct AllSkipped { #[test] fn test_patchable_model_and_derive_generate_patch_types_without_serde() { fn assert_patchable() {} - fn assert_patch_debug() - where - T::Patch: core::fmt::Debug, - { - } assert_patchable::(); assert_patchable::>(); assert_patchable::(); assert_patchable::(); - - assert_patch_debug::(); - assert_patch_debug::>(); - assert_patch_debug::(); - assert_patch_debug::(); } #[test] From ae3d9adcef98a4e35e3e2b82c64dd78fd8d84ca2 Mon Sep 17 00:00:00 2001 From: "Lan, Jian" Date: Mon, 16 Feb 2026 00:37:36 +0800 Subject: [PATCH 2/2] fix: correct CI --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7c7d430..9bcaa9a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -211,7 +211,7 @@ jobs: fi echo "Coverage regression detected. Evaluating relaxed thresholds..." - if awk -v func="${CURRENT_FUNCTION_COVERAGE}" -v line="${CURRENT_LINE_COVERAGE}" -v region="${CURRENT_REGION_COVERAGE}" 'BEGIN { exit (func + 1e-9 >= 100.0 && line + 1e-9 >= 90.0 && region + 1e-9 >= 90.0) ? 0 : 1 }'; then + if awk -v fns="${CURRENT_FUNCTION_COVERAGE}" -v line="${CURRENT_LINE_COVERAGE}" -v region="${CURRENT_REGION_COVERAGE}" 'BEGIN { exit (fns + 1e-9 >= 100.0 && line + 1e-9 >= 90.0 && region + 1e-9 >= 90.0) ? 0 : 1 }'; then echo "Coverage status: acceptable regression (functions >= 100%, lines >= 90%, regions >= 90%)." { echo ""