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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
23 changes: 9 additions & 14 deletions patchable-macro/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down Expand Up @@ -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<F>(&self, mut build_bounds: F) -> TokenStream2
fn build_where_clause_for_patchable_types<F>(&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)
}
Expand Down
10 changes: 0 additions & 10 deletions patchable/tests/no_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,11 @@ struct AllSkipped {
#[test]
fn test_patchable_model_and_derive_generate_patch_types_without_serde() {
fn assert_patchable<T: patchable::Patchable + patchable::Patch>() {}
fn assert_patch_debug<T: patchable::Patchable>()
where
T::Patch: core::fmt::Debug,
{
}

assert_patchable::<PlainInner>();
assert_patchable::<PlainOuter<PlainInner>>();
assert_patchable::<DeriveOnlyStruct>();
assert_patchable::<AllSkipped>();

assert_patch_debug::<PlainInner>();
assert_patch_debug::<PlainOuter<PlainInner>>();
assert_patch_debug::<DeriveOnlyStruct>();
assert_patch_debug::<AllSkipped>();
}

#[test]
Expand Down