diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 9dd2198b81..0e83b961ca 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -106,7 +106,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -625,7 +625,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -680,7 +680,7 @@ dependencies = [ "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -801,7 +801,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1260,7 +1260,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1480,7 +1480,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2288,7 +2288,7 @@ dependencies = [ "proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2434,7 +2434,7 @@ dependencies = [ "proc-macro-hack 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2516,7 +2516,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2994,7 +2994,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3119,7 +3119,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3169,7 +3169,7 @@ dependencies = [ "substrate-primitives 1.0.0", "substrate-state-machine 1.0.0", "substrate-test-client 1.0.0", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3531,7 +3531,7 @@ dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-macros 1.0.0", "srml-support-procedural-tools 1.0.0", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3542,7 +3542,7 @@ dependencies = [ "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "srml-support-procedural-tools-derive 1.0.0", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3551,7 +3551,7 @@ version = "1.0.0" dependencies = [ "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3648,7 +3648,7 @@ dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3663,7 +3663,7 @@ dependencies = [ "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3706,7 +3706,7 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3722,7 +3722,7 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4522,7 +4522,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "0.15.31" +version = "0.15.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4537,7 +4537,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5142,7 +5142,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5172,7 +5172,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5192,7 +5192,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "weedle 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5714,7 +5714,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum substrate-bip39 0.2.1 (git+https://github.com/paritytech/substrate-bip39)" = "" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" "checksum subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "702662512f3ddeb74a64ce2fbbf3707ee1b6bb663d28bb054e0779bbc720d926" -"checksum syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)" = "d2b4cfac95805274c6afdb12d8f770fa2d27c045953e7b630a81801953699a9a" +"checksum syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)" = "846620ec526c1599c070eff393bfeeeb88a93afa2513fc3b49f1fea84cf7b0ed" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum sysinfo 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b5a0cb7899e248ed0baa6ef6f8406352523c2f99bc7c4b1800f4cd6d5dde99eb" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" diff --git a/substrate/srml/support/procedural/Cargo.toml b/substrate/srml/support/procedural/Cargo.toml index 26b648da0c..0f7586a795 100644 --- a/substrate/srml/support/procedural/Cargo.toml +++ b/substrate/srml/support/procedural/Cargo.toml @@ -13,6 +13,4 @@ sr-api-macros = { path = "../../../core/sr-api-macros" } proc-macro2 = "0.4.27" quote = { version = "0.6.12" } -# FIXME: https://github.com/paritytech/substrate/issues/2326 -# Remove this restriction once the dependency on erstwhile CustomKeyword trait is removed -syn = { version = ">= 0.15.30, < 0.15.32", features = ["full"] } +syn = { version = "0.15.32", features = ["full"] } diff --git a/substrate/srml/support/procedural/src/storage/mod.rs b/substrate/srml/support/procedural/src/storage/mod.rs index 649a48a181..1d9e62bdd7 100644 --- a/substrate/srml/support/procedural/src/storage/mod.rs +++ b/substrate/srml/support/procedural/src/storage/mod.rs @@ -18,11 +18,8 @@ //! `decl_storage` macro // end::description[] -use srml_support_procedural_tools::syn_ext as ext; -use srml_support_procedural_tools::{ToTokens, Parse, custom_keyword, custom_keyword_impl}; - +use srml_support_procedural_tools::{ToTokens, Parse, syn_ext as ext}; use syn::{Ident, Token}; -use syn::token::CustomKeyword; use proc_macro2::TokenStream as TokenStream2; use quote::quote; @@ -30,10 +27,28 @@ mod impls; pub mod transformation; +mod keyword { + syn::custom_keyword!(hiddencrate); + syn::custom_keyword!(add_extra_genesis); + syn::custom_keyword!(extra_genesis_skip_phantom_data_field); + syn::custom_keyword!(config); + syn::custom_keyword!(build); + syn::custom_keyword!(get); + syn::custom_keyword!(map); + syn::custom_keyword!(linked_map); + syn::custom_keyword!(double_map); + syn::custom_keyword!(blake2_256); + syn::custom_keyword!(blake2_128); + syn::custom_keyword!(twox_256); + syn::custom_keyword!(twox_128); + syn::custom_keyword!(twox_64_concat); + syn::custom_keyword!(hasher); +} + /// Parsing usage only #[derive(Parse, ToTokens, Debug)] struct StorageDefinition { - pub hidden_crate: Option, + pub hidden_crate: ext::Opt, pub visibility: syn::Visibility, pub trait_token: Token![trait], pub ident: Ident, @@ -51,25 +66,25 @@ struct StorageDefinition { pub as_token: Token![as], pub crate_ident: Ident, pub content: ext::Braces>, - pub extra_genesis: Option, - pub extra_genesis_skip_phantom_data_field: Option, + pub extra_genesis: ext::Opt, + pub extra_genesis_skip_phantom_data_field: ext::Opt, } #[derive(Parse, ToTokens, Debug)] struct SpecificHiddenCrate { - pub keyword: ext::CustomToken, + pub keyword: keyword::hiddencrate, pub ident: ext::Parens, } #[derive(Parse, ToTokens, Debug)] struct AddExtraGenesis { - pub extragenesis_keyword: ext::CustomToken, + pub extragenesis_keyword: keyword::add_extra_genesis, pub content: ext::Braces, } #[derive(Parse, ToTokens, Debug)] struct ExtraGenesisSkipPhantomDataField { - pub genesis_phantom_keyword: ext::CustomToken, + pub genesis_phantom_keyword: keyword::extra_genesis_skip_phantom_data_field, pub token: Token![;], } @@ -87,7 +102,7 @@ enum AddExtraGenesisLineEnum { #[derive(Parse, ToTokens, Debug)] struct AddExtraGenesisLine { pub attrs: ext::OuterAttributes, - pub config_keyword: ext::CustomToken, + pub config_keyword: keyword::config, pub extra_field: ext::Parens, pub coldot_token: Token![:], pub extra_type: syn::Type, @@ -102,9 +117,9 @@ struct DeclStorageLine { pub visibility: syn::Visibility, // name pub name: Ident, - pub getter: Option, - pub config: Option, - pub build: Option, + pub getter: ext::Opt, + pub config: ext::Opt, + pub build: ext::Opt, pub coldot_token: Token![:], pub storage_type: DeclStorageType, pub default_value: ext::Opt, @@ -113,19 +128,19 @@ struct DeclStorageLine { #[derive(Parse, ToTokens, Debug)] struct DeclStorageGetter { - pub getter_keyword: ext::CustomToken, + pub getter_keyword: keyword::get, pub getfn: ext::Parens, } #[derive(Parse, ToTokens, Debug)] struct DeclStorageConfig { - pub config_keyword: ext::CustomToken, + pub config_keyword: keyword::config, pub expr: ext::Parens>, } #[derive(Parse, ToTokens, Debug)] struct DeclStorageBuild { - pub build_keyword: ext::CustomToken, + pub build_keyword: keyword::build, pub expr: ext::Parens, } @@ -139,8 +154,8 @@ enum DeclStorageType { #[derive(Parse, ToTokens, Debug)] struct DeclStorageMap { - pub map_keyword: ext::CustomToken, - pub hasher: Option, + pub map_keyword: keyword::map, + pub hasher: ext::Opt, pub key: syn::Type, pub ass_keyword: Token![=>], pub value: syn::Type, @@ -148,8 +163,8 @@ struct DeclStorageMap { #[derive(Parse, ToTokens, Debug)] struct DeclStorageLinkedMap { - pub map_keyword: ext::CustomToken, - pub hasher: Option, + pub map_keyword: keyword::linked_map, + pub hasher: ext::Opt, pub key: syn::Type, pub ass_keyword: Token![=>], pub value: syn::Type, @@ -157,8 +172,8 @@ struct DeclStorageLinkedMap { #[derive(Parse, ToTokens, Debug)] struct DeclStorageDoubleMap { - pub map_keyword: ext::CustomToken, - pub hasher: Option, + pub map_keyword: keyword::double_map, + pub hasher: ext::Opt, pub key1: syn::Type, pub comma_keyword: Token![,], pub key2_hasher: Hasher, @@ -169,11 +184,11 @@ struct DeclStorageDoubleMap { #[derive(Parse, ToTokens, Debug)] enum Hasher { - Blake2_256(ext::CustomToken), - Blake2_128(ext::CustomToken), - Twox256(ext::CustomToken), - Twox128(ext::CustomToken), - Twox64Concat(ext::CustomToken), + Blake2_256(keyword::blake2_256), + Blake2_128(keyword::blake2_128), + Twox256(keyword::twox_256), + Twox128(keyword::twox_128), + Twox64Concat(keyword::twox_64_concat), } #[derive(Parse, ToTokens, Debug)] @@ -184,7 +199,7 @@ struct DeclStorageDefault { #[derive(Parse, ToTokens, Debug)] struct SetHasher { - pub hasher_keyword: ext::CustomToken, + pub hasher_keyword: keyword::hasher, pub inner: ext::Parens, } @@ -239,21 +254,3 @@ impl HasherKind { } } } - -custom_keyword_impl!(SpecificHiddenCrate, "hiddencrate", "hiddencrate as keyword"); -custom_keyword_impl!(DeclStorageConfig, "config", "build as keyword"); -custom_keyword!(ConfigKeyword, "config", "config as keyword"); -custom_keyword!(BuildKeyword, "build", "build as keyword"); -custom_keyword_impl!(DeclStorageBuild, "build", "storage build config"); -custom_keyword_impl!(AddExtraGenesis, "add_extra_genesis", "storage extra genesis"); -custom_keyword_impl!(DeclStorageGetter, "get", "storage getter"); -custom_keyword!(MapKeyword, "map", "map as keyword"); -custom_keyword!(LinkedMapKeyword, "linked_map", "linked_map as keyword"); -custom_keyword!(DoubleMapKeyword, "double_map", "double_map as keyword"); -custom_keyword!(Blake2_256Keyword, "blake2_256", "Blake2_256 as keyword"); -custom_keyword!(Blake2_128Keyword, "blake2_128", "Blake2_128 as keyword"); -custom_keyword!(Twox256Keyword, "twox_256", "Twox256 as keyword"); -custom_keyword!(Twox128Keyword, "twox_128", "Twox128 as keyword"); -custom_keyword!(Twox64ConcatKeyword, "twox_64_concat", "Twox64Concat as keyword"); -custom_keyword_impl!(ExtraGenesisSkipPhantomDataField, "extra_genesis_skip_phantom_data_field", "extra_genesis_skip_phantom_data_field as keyword"); -custom_keyword_impl!(SetHasher, "hasher", "storage hasher"); diff --git a/substrate/srml/support/procedural/src/storage/transformation.rs b/substrate/srml/support/procedural/src/storage/transformation.rs index 205fccdea5..04b2b832b6 100644 --- a/substrate/srml/support/procedural/src/storage/transformation.rs +++ b/substrate/srml/support/procedural/src/storage/transformation.rs @@ -74,7 +74,7 @@ pub fn decl_storage_impl(input: TokenStream) -> TokenStream { Err(err) => return err.to_compile_error().into(), }; - let hidden_crate_name = hidden_crate.map(|rc| rc.ident.content).map(|i| i.to_string()) + let hidden_crate_name = hidden_crate.inner.map(|rc| rc.ident.content).map(|i| i.to_string()) .unwrap_or_else(|| "decl_storage".to_string()); let scrate = generate_crate_access(&hidden_crate_name, "srml-support"); let scrate_decl = generate_hidden_includes( @@ -103,8 +103,8 @@ pub fn decl_storage_impl(input: TokenStream) -> TokenStream { &traittype, &instance_opts, &storage_lines, - &extra_genesis, - extra_genesis_skip_phantom_data_field.is_some(), + &extra_genesis.inner, + extra_genesis_skip_phantom_data_field.inner.is_some(), )); let decl_storage_items = decl_storage_items( &scrate, @@ -219,10 +219,10 @@ fn decl_store_extra_genesis( let mut opt_build; // need build line - if let Some(ref config) = config { + if let Some(ref config) = config.inner { let ident = if let Some(ident) = config.expr.content.as_ref() { quote!( #ident ) - } else if let Some(ref getter) = getter { + } else if let Some(ref getter) = getter.inner { let ident = &getter.getfn.content; quote!( #ident ) } else { @@ -259,7 +259,7 @@ fn decl_store_extra_genesis( quote!( #( #[ #attrs ] )* pub #ident: Vec<(#key1_type, #key2_type, #storage_type)>, ) }, }); - opt_build = Some(build.as_ref().map(|b| &b.expr.content).map(|b|quote!( #b )) + opt_build = Some(build.inner.as_ref().map(|b| &b.expr.content).map(|b|quote!( #b )) .unwrap_or_else(|| quote!( (|config: &GenesisConfig<#traitinstance, #instance>| config.#ident.clone()) ))); let fielddefault = default_value.inner.as_ref().map(|d| &d.expr).map(|d| @@ -271,7 +271,7 @@ fn decl_store_extra_genesis( config_field_default.extend(quote!( #ident: #fielddefault, )); } else { - opt_build = build.as_ref().map(|b| &b.expr.content).map(|b| quote!( #b )); + opt_build = build.inner.as_ref().map(|b| &b.expr.content).map(|b| quote!( #b )); } let typ = type_infos.typ; @@ -647,7 +647,7 @@ fn impl_store_fns( .. } = sline; - if let Some(getter) = getter { + if let Some(getter) = getter.inner.as_ref() { let get_fn = &getter.getfn.content; let type_infos = get_type_infos(storage_type); @@ -877,17 +877,17 @@ fn get_type_infos(storage_type: &DeclStorageType) -> DeclStorageTypeInfos { let (value_type, kind) = match storage_type { DeclStorageType::Simple(ref st) => (st, DeclStorageTypeInfosKind::Simple), DeclStorageType::Map(ref map) => (&map.value, DeclStorageTypeInfosKind::Map { - hasher: map.hasher.as_ref().map(|h| h.into()).unwrap_or(HasherKind::Blake2_256), + hasher: map.hasher.inner.as_ref().map(|h| h.into()).unwrap_or(HasherKind::Blake2_256), key_type: &map.key, is_linked: false, }), DeclStorageType::LinkedMap(ref map) => (&map.value, DeclStorageTypeInfosKind::Map { - hasher: map.hasher.as_ref().map(|h| h.into()).unwrap_or(HasherKind::Blake2_256), + hasher: map.hasher.inner.as_ref().map(|h| h.into()).unwrap_or(HasherKind::Blake2_256), key_type: &map.key, is_linked: true, }), DeclStorageType::DoubleMap(ref map) => (&map.value, DeclStorageTypeInfosKind::DoubleMap { - hasher: map.hasher.as_ref().map(|h| h.into()).unwrap_or(HasherKind::Blake2_256), + hasher: map.hasher.inner.as_ref().map(|h| h.into()).unwrap_or(HasherKind::Blake2_256), key1_type: &map.key1, key2_type: &map.key2.content, key2_hasher: { let h = &map.key2_hasher; quote! { #h } }, diff --git a/substrate/srml/support/procedural/tools/src/lib.rs b/substrate/srml/support/procedural/tools/src/lib.rs index 34b96df810..fd7dd41391 100644 --- a/substrate/srml/support/procedural/tools/src/lib.rs +++ b/substrate/srml/support/procedural/tools/src/lib.rs @@ -27,30 +27,6 @@ use quote::quote; pub mod syn_ext; -#[macro_export] -macro_rules! custom_keyword_impl { - ($name:ident, $keyident:expr, $keydisp:expr) => { - - impl CustomKeyword for $name { - fn ident() -> &'static str { $keyident } - fn display() -> &'static str { $keydisp } - } - - } -} - -#[macro_export] -macro_rules! custom_keyword { - ($name:ident, $keyident:expr, $keydisp:expr) => { - - #[derive(Debug)] - struct $name; - - custom_keyword_impl!($name, $keyident, $keydisp); - - } -} - // FIXME #1569, remove the following functions, which are copied from sr-api-macros use proc_macro2::{TokenStream, Span}; use syn::Ident; diff --git a/substrate/srml/support/procedural/tools/src/syn_ext.rs b/substrate/srml/support/procedural/tools/src/syn_ext.rs index c6b0b4aefb..01177b9b3e 100644 --- a/substrate/srml/support/procedural/tools/src/syn_ext.rs +++ b/substrate/srml/support/procedural/tools/src/syn_ext.rs @@ -23,7 +23,6 @@ use syn::parse::{ ParseStream, Result, }; -use syn::token::CustomKeyword; use proc_macro2::TokenStream as T2; use quote::{ToTokens, quote}; use std::iter::once; @@ -72,32 +71,6 @@ groups_impl!(Braces, Brace, Brace, parse_braces); groups_impl!(Brackets, Bracket, Bracket, parse_brackets); groups_impl!(Parens, Paren, Parenthesis, parse_parens); -#[derive(Debug, Clone)] -pub struct CustomToken(std::marker::PhantomData); - -impl Parse for CustomToken { - fn parse(input: ParseStream) -> Result { - let ident: syn::Ident = input.parse()?; - - if ident.to_string().as_str() != T::ident() { - return Err(syn::parse::Error::new_spanned(ident, "expected another custom token")) - } - Ok(CustomToken(std::marker::PhantomData)) - } -} - -impl ToTokens for CustomToken { - fn to_tokens(&self, tokens: &mut T2) { - use std::str::FromStr; - tokens.extend(T2::from_str(T::ident()).expect("custom keyword should parse to ident")); - } -} - -impl CustomKeyword for CustomToken { - fn ident() -> &'static str { ::ident() } - fn display() -> &'static str { ::display() } -} - #[derive(Debug)] pub struct PunctuatedInner { pub inner: syn::punctuated::Punctuated,