From 4e3db04aea7b590033ecae81ba1e39a4f16574e8 Mon Sep 17 00:00:00 2001 From: alexgparity Date: Tue, 10 Jan 2023 11:04:03 +0100 Subject: [PATCH 1/6] Add solution hint to error message --- frame/support/procedural/src/pallet/expand/hooks.rs | 2 +- frame/support/procedural/src/pallet/expand/storage.rs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/frame/support/procedural/src/pallet/expand/hooks.rs b/frame/support/procedural/src/pallet/expand/hooks.rs index 0aa7c1e7aaf06..73eb6092c0ef6 100644 --- a/frame/support/procedural/src/pallet/expand/hooks.rs +++ b/frame/support/procedural/src/pallet/expand/hooks.rs @@ -63,7 +63,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { ::PalletInfo as #frame_support::traits::PalletInfo - >::name::().expect("Every active pallet has a name in the runtime; qed"); + >::name::().expect("Every active pallet has a name in the runtime; qed. Have you added the pallet into construct_runtime! ?"); #frame_support::log::debug!( target: #frame_support::LOG_TARGET, "🩺 try-state pallet {:?}", diff --git a/frame/support/procedural/src/pallet/expand/storage.rs b/frame/support/procedural/src/pallet/expand/storage.rs index 181f35b545496..06a3feb256d71 100644 --- a/frame/support/procedural/src/pallet/expand/storage.rs +++ b/frame/support/procedural/src/pallet/expand/storage.rs @@ -328,6 +328,8 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream { let frame_system = &def.frame_system; let pallet_ident = &def.pallet_struct.pallet; + let err_msg = "Every active pallet has a name in the runtime; qed. Have you added the pallet into construct_runtime! ?"; + let entries_builder = def.storages.iter().map(|storage| { let no_docs = vec![]; let docs = if cfg!(feature = "no-metadata-docs") { &no_docs } else { &storage.docs }; @@ -535,7 +537,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream { ::PalletInfo as #frame_support::traits::PalletInfo >::name::>() - .expect("Every active pallet has a name in the runtime; qed") + .expect(err_msg) } const STORAGE_PREFIX: &'static str = #counter_prefix_struct_const; } @@ -569,7 +571,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream { ::PalletInfo as #frame_support::traits::PalletInfo >::name::>() - .expect("Every active pallet has a name in the runtime; qed") + .expect(err_msg) } const STORAGE_PREFIX: &'static str = #prefix_struct_const; } @@ -648,7 +650,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream { ::PalletInfo as #frame_support::traits::PalletInfo >::name::<#pallet_ident<#type_use_gen>>() - .expect("Every active pallet has a name in the runtime; qed"), + .expect(err_msg), entries: { #[allow(unused_mut)] let mut entries = #frame_support::sp_std::vec![]; From af4ee792d53dfd5f37ae9fa2b1f2e05d280f489b Mon Sep 17 00:00:00 2001 From: alexgparity Date: Tue, 10 Jan 2023 11:25:33 +0100 Subject: [PATCH 2/6] make it compile --- frame/support/procedural/src/pallet/expand/storage.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/frame/support/procedural/src/pallet/expand/storage.rs b/frame/support/procedural/src/pallet/expand/storage.rs index 06a3feb256d71..3a0fa555ac29b 100644 --- a/frame/support/procedural/src/pallet/expand/storage.rs +++ b/frame/support/procedural/src/pallet/expand/storage.rs @@ -328,8 +328,6 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream { let frame_system = &def.frame_system; let pallet_ident = &def.pallet_struct.pallet; - let err_msg = "Every active pallet has a name in the runtime; qed. Have you added the pallet into construct_runtime! ?"; - let entries_builder = def.storages.iter().map(|storage| { let no_docs = vec![]; let docs = if cfg!(feature = "no-metadata-docs") { &no_docs } else { &storage.docs }; @@ -537,7 +535,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream { ::PalletInfo as #frame_support::traits::PalletInfo >::name::>() - .expect(err_msg) + .expect("Every active pallet has a name in the runtime; qed. Have you added the pallet into construct_runtime! ?") } const STORAGE_PREFIX: &'static str = #counter_prefix_struct_const; } @@ -571,7 +569,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream { ::PalletInfo as #frame_support::traits::PalletInfo >::name::>() - .expect(err_msg) + .expect("Every active pallet has a name in the runtime; qed. Have you added the pallet into construct_runtime! ?") } const STORAGE_PREFIX: &'static str = #prefix_struct_const; } @@ -650,7 +648,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream { ::PalletInfo as #frame_support::traits::PalletInfo >::name::<#pallet_ident<#type_use_gen>>() - .expect(err_msg), + .expect("Every active pallet has a name in the runtime; qed. Have you added the pallet into construct_runtime! ?"), entries: { #[allow(unused_mut)] let mut entries = #frame_support::sp_std::vec![]; From 21d9405ca7a820b56f4899e8504136b8a0defdd4 Mon Sep 17 00:00:00 2001 From: alexgparity <115470171+alexgparity@users.noreply.github.com> Date: Tue, 10 Jan 2023 12:05:27 +0100 Subject: [PATCH 3/6] Update frame/support/procedural/src/pallet/expand/hooks.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- frame/support/procedural/src/pallet/expand/hooks.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/procedural/src/pallet/expand/hooks.rs b/frame/support/procedural/src/pallet/expand/hooks.rs index 73eb6092c0ef6..c2b70c5632f94 100644 --- a/frame/support/procedural/src/pallet/expand/hooks.rs +++ b/frame/support/procedural/src/pallet/expand/hooks.rs @@ -63,7 +63,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { ::PalletInfo as #frame_support::traits::PalletInfo - >::name::().expect("Every active pallet has a name in the runtime; qed. Have you added the pallet into construct_runtime! ?"); + >::name::().expect("No name found for the pallet! This usually means that the pallet wasn't added to `construct_runtime!`."); #frame_support::log::debug!( target: #frame_support::LOG_TARGET, "🩺 try-state pallet {:?}", From d00654be79d3696c42867c43ee1c1e2e70ce78e8 Mon Sep 17 00:00:00 2001 From: alexgparity <115470171+alexgparity@users.noreply.github.com> Date: Tue, 10 Jan 2023 12:05:33 +0100 Subject: [PATCH 4/6] Update frame/support/procedural/src/pallet/expand/storage.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- frame/support/procedural/src/pallet/expand/storage.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/procedural/src/pallet/expand/storage.rs b/frame/support/procedural/src/pallet/expand/storage.rs index 3a0fa555ac29b..7ce6a83505711 100644 --- a/frame/support/procedural/src/pallet/expand/storage.rs +++ b/frame/support/procedural/src/pallet/expand/storage.rs @@ -535,7 +535,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream { ::PalletInfo as #frame_support::traits::PalletInfo >::name::>() - .expect("Every active pallet has a name in the runtime; qed. Have you added the pallet into construct_runtime! ?") + .expect("No name found for the pallet in the runtime! This usually means that the pallet wasn't added to `construct_runtime!`.") } const STORAGE_PREFIX: &'static str = #counter_prefix_struct_const; } From 087e42a46478edd3c90c19a8223c5a5f53d23cbd Mon Sep 17 00:00:00 2001 From: alexgparity <115470171+alexgparity@users.noreply.github.com> Date: Tue, 10 Jan 2023 12:05:39 +0100 Subject: [PATCH 5/6] Update frame/support/procedural/src/pallet/expand/storage.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- frame/support/procedural/src/pallet/expand/storage.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/procedural/src/pallet/expand/storage.rs b/frame/support/procedural/src/pallet/expand/storage.rs index 7ce6a83505711..097215df59b47 100644 --- a/frame/support/procedural/src/pallet/expand/storage.rs +++ b/frame/support/procedural/src/pallet/expand/storage.rs @@ -569,7 +569,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream { ::PalletInfo as #frame_support::traits::PalletInfo >::name::>() - .expect("Every active pallet has a name in the runtime; qed. Have you added the pallet into construct_runtime! ?") + .expect("No name found for the pallet in the runtime! This usually means that the pallet wasn't added to `construct_runtime!`.") } const STORAGE_PREFIX: &'static str = #prefix_struct_const; } From 70c92d8fa524893b494602c7cdd65d7f82ed543e Mon Sep 17 00:00:00 2001 From: alexgparity <115470171+alexgparity@users.noreply.github.com> Date: Tue, 10 Jan 2023 12:05:46 +0100 Subject: [PATCH 6/6] Update frame/support/procedural/src/pallet/expand/storage.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- frame/support/procedural/src/pallet/expand/storage.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/procedural/src/pallet/expand/storage.rs b/frame/support/procedural/src/pallet/expand/storage.rs index 097215df59b47..195a62431f279 100644 --- a/frame/support/procedural/src/pallet/expand/storage.rs +++ b/frame/support/procedural/src/pallet/expand/storage.rs @@ -648,7 +648,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream { ::PalletInfo as #frame_support::traits::PalletInfo >::name::<#pallet_ident<#type_use_gen>>() - .expect("Every active pallet has a name in the runtime; qed. Have you added the pallet into construct_runtime! ?"), + .expect("No name found for the pallet in the runtime! This usually means that the pallet wasn't added to `construct_runtime!`."), entries: { #[allow(unused_mut)] let mut entries = #frame_support::sp_std::vec![];