diff --git a/bok-macro/src/pkgs.rs b/bok-macro/src/pkgs.rs index 38082cf..f454507 100644 --- a/bok-macro/src/pkgs.rs +++ b/bok-macro/src/pkgs.rs @@ -73,7 +73,7 @@ pub(crate) fn package( .into(); }; let generic_struct: ::syn::ItemStruct = ::syn::parse_quote! { - pub struct test where R: ::std::fmt::Debug + 'static {} + pub struct test where R: ::bok::Repository + 'static {} }; let (_, generics, where_clause) = generic_struct.generics.split_for_impl(); @@ -506,7 +506,7 @@ pub(crate) fn package_impl_base_add( let generic_struct: ::syn::ItemImpl = ::syn::parse_quote! { impl test for #pkg_type where - R: ::std::fmt::Debug + 'static + R: ::bok::Repository + 'static {} }; @@ -775,7 +775,7 @@ pub(crate) fn derive_package(input: TokenStream) -> TokenStream { let expanded = quote! { impl ::core::fmt::Display for #name where - R: ::std::fmt::Debug + R: ::bok::Repository, { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) ->::core::fmt::Result @@ -785,7 +785,7 @@ pub(crate) fn derive_package(input: TokenStream) -> TokenStream { } impl ::bok::PkgCode for #name where - R: ::std::fmt::Debug +'static + R: ::bok::Repository +'static, { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) ->::core::fmt::Result @@ -848,7 +848,7 @@ pub(crate) fn derive_package(input: TokenStream) -> TokenStream { } impl #name where - R: ::std::fmt::Debug +'static + ::core::default::Default + R: ::bok::Repository + 'static + ::core::default::Default, { pub fn as_pkg(&self) -> &dyn ::bok::Pkg { self @@ -869,7 +869,7 @@ pub(crate) fn derive_package(input: TokenStream) -> TokenStream { #[derive(::std::default::Default, ::std::fmt::Debug)] pub struct #name_builder where - R: ::std::fmt::Debug +'static + R: ::bok::Repository + 'static, { _bok_repo: ::std::marker::PhantomData, #(#non_opt_fields: ::std::option::Option<#non_opt_types>,)* @@ -877,7 +877,7 @@ pub(crate) fn derive_package(input: TokenStream) -> TokenStream { } impl ::bok::PkgBuilder for #name_builder2 where - R: ::std::fmt::Debug + 'static + R: ::bok::Repository + 'static, { fn name(&self) -> ::bok::PkgName { use ::bok::Pkg; @@ -916,7 +916,7 @@ pub(crate) fn derive_package(input: TokenStream) -> TokenStream { } impl #name_builder3 where - R: ::std::fmt::Debug +'static + R: ::bok::Repository +'static, { pub fn as_any(&self) -> &dyn ::std::any::Any { self diff --git a/bok-macro/src/repos.rs b/bok-macro/src/repos.rs index 783dfb7..7f1a397 100644 --- a/bok-macro/src/repos.rs +++ b/bok-macro/src/repos.rs @@ -538,6 +538,18 @@ pub(crate) fn repo_impl_methods( fn_to_add.push(pkg_fn); } + // keep sorted for easier debugging when expanding macros + fn_to_add + .sort_by(|a, b| a.sig.ident.to_string().cmp(&b.sig.ident.to_string())); + all_pkgs_types.sort_by(|a, b| { + a.segments + .last() + .unwrap() + .ident + .to_string() + .cmp(&b.segments.last().unwrap().ident.to_string()) + }); + let new_fn = fn_to_add.iter(); let mut all_impl_deps = Vec::with_capacity(all_pkgs_types.len()); @@ -556,7 +568,6 @@ pub(crate) fn repo_impl_methods( impl #bok_dep_trait for #local_ident {} }; all_impl_deps.push(dep_view); - break; } quote! { @@ -586,7 +597,7 @@ pub(crate) fn repo_impl_pkg_deps( .expect("#[::bok_macro::repo_impl_pkg_deps()]: no trait found") .1; let local_attrs = local.attrs.iter(); - let (_, generics, where_clause) = local.generics.split_for_impl(); + let (_, generics, _) = local.generics.split_for_impl(); let ident = &local.self_ty; //let deps = Vec::<::syn::TraitItemFn>::new(); @@ -611,7 +622,7 @@ pub(crate) fn repo_impl_pkg_deps( quote! { #(#local_attrs) * - impl #impl_trait for #ident #generics #where_clause { + impl #impl_trait for #ident #generics { #(#deps) * } diff --git a/bok-utils/src/repos/pkgs/one.rs b/bok-utils/src/repos/pkgs/one.rs index a4d592d..4cb95a5 100644 --- a/bok-utils/src/repos/pkgs/one.rs +++ b/bok-utils/src/repos/pkgs/one.rs @@ -27,7 +27,7 @@ pub struct One { impl ::std::default::Default for One where - R: ::std::fmt::Debug, + R: ::bok::Repository, { fn default() -> Self { One { diff --git a/bok-utils/src/repos/pkgs/three.rs b/bok-utils/src/repos/pkgs/three.rs index 742969b..fcba6af 100644 --- a/bok-utils/src/repos/pkgs/three.rs +++ b/bok-utils/src/repos/pkgs/three.rs @@ -26,7 +26,7 @@ pub struct Three { impl ::std::default::Default for Three where - R: ::std::fmt::Debug, + R: ::bok::Repository, { fn default() -> Self { Three { diff --git a/bok-utils/src/repos/pkgs/two.rs b/bok-utils/src/repos/pkgs/two.rs index ea46aa7..8454aba 100644 --- a/bok-utils/src/repos/pkgs/two.rs +++ b/bok-utils/src/repos/pkgs/two.rs @@ -26,7 +26,7 @@ pub struct Two { impl ::std::default::Default for Two where - R: ::std::fmt::Debug, + R: ::bok::Repository, { fn default() -> Self { Two {