From c7e7b8b0125ec1f4ae4d681ecf76c34d1c28624e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sat, 6 Jul 2019 13:56:55 +0200 Subject: [PATCH] Document limitations of `decl_storage!` with instancing (#3044) --- substrate/srml/support/procedural/src/lib.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/substrate/srml/support/procedural/src/lib.rs b/substrate/srml/support/procedural/src/lib.rs index 2d35a237c6..b8bcb15de1 100644 --- a/substrate/srml/support/procedural/src/lib.rs +++ b/substrate/srml/support/procedural/src/lib.rs @@ -147,6 +147,25 @@ use proc_macro::TokenStream; /// ```nocompile /// trait Store for Module as Example where T::AccountId: std::fmt::Display {} /// ``` +/// +/// ## Limitations +/// +/// # Instancing and generic `GenesisConfig` +/// +/// If your module supports instancing and you see an error like `parameter `I` is never used` for +/// your `decl_storage!`, you are hitting a limitation of the current implementation. You probably +/// try to use an associated type of a non-instantiable trait. To solve this, add the following to +/// your macro call: +/// +/// ```nocompile +/// add_extra_genesis { +/// config(phantom): std::marker::PhantomData, +/// } +/// ... +/// +/// This adds a field to your `GenesisConfig` with the name `phantom` that you can initialize with +/// `Default::default()`. +/// #[proc_macro] pub fn decl_storage(input: TokenStream) -> TokenStream { storage::transformation::decl_storage_impl(input)