From 4fcd20854ccad2c9d4dbff49db3cc75cc8bff4e4 Mon Sep 17 00:00:00 2001 From: kianenigma Date: Sat, 28 Jan 2023 20:52:42 -0300 Subject: [PATCH 1/3] hooks default impl missing where clause --- 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 c41a65b57b57a..987d0691b1ecc 100644 --- a/frame/support/procedural/src/pallet/expand/hooks.rs +++ b/frame/support/procedural/src/pallet/expand/hooks.rs @@ -76,7 +76,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { quote::quote! { impl<#type_impl_gen> #frame_support::traits::Hooks<::BlockNumber> - for Pallet<#type_use_gen> {} + for #pallet_ident<#type_use_gen> #where_clause {} } } else { proc_macro2::TokenStream::new() From 53ee3bdd60f0a9eeaf914165ecdf0ea91407f609 Mon Sep 17 00:00:00 2001 From: kianenigma Date: Sat, 28 Jan 2023 21:06:54 -0300 Subject: [PATCH 2/3] add tests --- .../tests/pallet_ui/duplicate_store_attr.rs | 3 +-- .../pass/where_clause_missing_hooks.rs | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs diff --git a/frame/support/test/tests/pallet_ui/duplicate_store_attr.rs b/frame/support/test/tests/pallet_ui/duplicate_store_attr.rs index d675ddefe985b..ab318034aca05 100644 --- a/frame/support/test/tests/pallet_ui/duplicate_store_attr.rs +++ b/frame/support/test/tests/pallet_ui/duplicate_store_attr.rs @@ -22,5 +22,4 @@ mod pallet { type Foo = StorageValue<_, u8>; } -fn main() { -} +fn main() {} diff --git a/frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs b/frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs new file mode 100644 index 0000000000000..5e0e6076f9b5d --- /dev/null +++ b/frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs @@ -0,0 +1,20 @@ +#[frame_support::pallet] +mod pallet { + #[pallet::config] + pub trait Config: frame_system::Config where ::Index: From {} + + #[pallet::pallet] + pub struct Pallet(core::marker::PhantomData); + + #[pallet::call] + impl Pallet where ::Index: From {} + + impl Pallet where ::Index: From { + fn foo(x: u128) { + let _index = ::Index::from(x); + } + } +} + +fn main() { +} From 2da63f7bacbeeb5bada08bbebc5e6f047639dd8b Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Wed, 1 Feb 2023 07:15:47 -0300 Subject: [PATCH 3/3] Update frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs --- .../test/tests/pallet_ui/pass/where_clause_missing_hooks.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs b/frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs index 5e0e6076f9b5d..bf5f22306207a 100644 --- a/frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs +++ b/frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs @@ -16,5 +16,4 @@ mod pallet { } } -fn main() { -} +fn main() {}