From 320a9ce3c926394f28da1817e5441cac67671800 Mon Sep 17 00:00:00 2001
From: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Date: Wed, 1 Feb 2023 10:38:41 -0300
Subject: [PATCH] hooks default impl missing where clause (#13264)

* hooks default impl missing where clause

* add tests

* Update frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs

---------

Co-authored-by: parity-processbot <>
---
 .../procedural/src/pallet/expand/hooks.rs     |  2 +-
 .../tests/pallet_ui/duplicate_store_attr.rs   |  3 +--
 .../pass/where_clause_missing_hooks.rs        | 19 +++++++++++++++++++
 3 files changed, 21 insertions(+), 3 deletions(-)
 create mode 100644 substrate/frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs

diff --git a/substrate/frame/support/procedural/src/pallet/expand/hooks.rs b/substrate/frame/support/procedural/src/pallet/expand/hooks.rs
index c41a65b57b5..987d0691b1e 100644
--- a/substrate/frame/support/procedural/src/pallet/expand/hooks.rs
+++ b/substrate/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<<T as #frame_system::Config>::BlockNumber>
-				for Pallet<#type_use_gen> {}
+				for #pallet_ident<#type_use_gen> #where_clause {}
 		}
 	} else {
 		proc_macro2::TokenStream::new()
diff --git a/substrate/frame/support/test/tests/pallet_ui/duplicate_store_attr.rs b/substrate/frame/support/test/tests/pallet_ui/duplicate_store_attr.rs
index d675ddefe98..ab318034aca 100644
--- a/substrate/frame/support/test/tests/pallet_ui/duplicate_store_attr.rs
+++ b/substrate/frame/support/test/tests/pallet_ui/duplicate_store_attr.rs
@@ -22,5 +22,4 @@ mod pallet {
 	type Foo<T> = StorageValue<_, u8>;
 }
 
-fn main() {
-}
+fn main() {}
diff --git a/substrate/frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs b/substrate/frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs
new file mode 100644
index 00000000000..bf5f2230620
--- /dev/null
+++ b/substrate/frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs
@@ -0,0 +1,19 @@
+#[frame_support::pallet]
+mod pallet {
+	#[pallet::config]
+	pub trait Config: frame_system::Config where <Self as frame_system::Config>::Index: From<u128> {}
+
+	#[pallet::pallet]
+	pub struct Pallet<T>(core::marker::PhantomData<T>);
+
+	#[pallet::call]
+	impl<T: Config> Pallet<T> where <T as frame_system::Config>::Index: From<u128> {}
+
+	impl<T: Config> Pallet<T> where <T as frame_system::Config>::Index: From<u128> {
+		fn foo(x: u128) {
+			let _index = <T as frame_system::Config>::Index::from(x);
+		}
+	}
+}
+
+fn main() {}
-- 
GitLab