From 0017471dd9717085f23224ca37f68f1c4bdaeffc Mon Sep 17 00:00:00 2001 From: Ilia Churin Date: Fri, 26 Aug 2022 18:52:33 +0900 Subject: [PATCH] [feature] #2626, #2588: Implement `Combine` derive, split `config` macros Signed-off-by: Ilia Churin --- config/base/derive/src/proxy.rs | 2 +- config/base/derive/src/utils.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/config/base/derive/src/proxy.rs b/config/base/derive/src/proxy.rs index 37d0019beeb..e7b915bb118 100644 --- a/config/base/derive/src/proxy.rs +++ b/config/base/derive/src/proxy.rs @@ -7,7 +7,7 @@ use crate::utils; pub fn impl_proxy(ast: StructWithFields) -> TokenStream { // somewhat awkward conversion, could it be better? - let parent_name = ast.ident.clone(); + let parent_name = &ast.ident; let parent_ty: Type = parse_quote! { #parent_name }; let proxy_struct = gen_proxy_struct(ast); let loadenv_derive = quote! { ::iroha_config_base::derive::LoadFromEnv }; diff --git a/config/base/derive/src/utils.rs b/config/base/derive/src/utils.rs index af2e8f718ae..52b490e5ba2 100644 --- a/config/base/derive/src/utils.rs +++ b/config/base/derive/src/utils.rs @@ -214,6 +214,7 @@ impl ToTokens for StructField { pub struct StructWithFields { pub attrs: Vec, pub env_prefix: String, + // pub parent_ty: Type, pub vis: syn::Visibility, _struct_token: Token![struct], pub ident: Ident, @@ -231,6 +232,12 @@ impl Parse for StructWithFields { .find_map(Result::ok) .map(|pref| pref.prefix.value()) .unwrap_or_default(); + // let parent_ty = attrs + // .iter() + // .map(Builder::::parse) + // .find_map(Result::ok) + // .map(|builder| builder.parent) + // .expect("???"); Ok(Self { attrs, vis: input.parse()?,