mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 11:41:04 +00:00
Reserve function name (#2609)
* reserve function name * bumpd impl version * Revert "bumpd impl version" This reverts commit 03a23e308312d857bdfd3c90ff564b4b11347530. * add test * update test * update lock * Fix test on stable
This commit is contained in:
committed by
Bastian Köcher
parent
062b734571
commit
57f306a3c1
@@ -874,6 +874,10 @@ macro_rules! decl_module {
|
||||
{ $( $on_finalize:tt )* }
|
||||
{ $( $offchain:tt )* }
|
||||
) => {
|
||||
$crate::__check_reserved_fn_name! {
|
||||
$($fn_name)*
|
||||
}
|
||||
|
||||
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
@@ -1201,6 +1205,38 @@ macro_rules! __function_to_metadata {
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
#[doc(hidden)]
|
||||
macro_rules! __check_reserved_fn_name {
|
||||
(deposit_event $( $rest:ident )*) => {
|
||||
$crate::__check_reserved_fn_name!(@compile_error deposit_event);
|
||||
};
|
||||
(on_initialize $( $rest:ident )*) => {
|
||||
$crate::__check_reserved_fn_name!(@compile_error on_initialize);
|
||||
};
|
||||
(on_initialise $( $rest:ident )*) => {
|
||||
$crate::__check_reserved_fn_name!(@compile_error on_initialise);
|
||||
};
|
||||
(on_finalize $( $rest:ident )*) => {
|
||||
$crate::__check_reserved_fn_name!(@compile_error on_finalize);
|
||||
};
|
||||
(on_finalise $( $rest:ident )*) => {
|
||||
$crate::__check_reserved_fn_name!(@compile_error on_finalise);
|
||||
};
|
||||
(offchain_worker $( $rest:ident )*) => {
|
||||
$crate::__check_reserved_fn_name!(@compile_error offchain_worker);
|
||||
};
|
||||
($t:ident $( $rest:ident )*) => {
|
||||
$crate::__check_reserved_fn_name!($( $rest )*);
|
||||
};
|
||||
() => {};
|
||||
(@compile_error $ident:ident) => {
|
||||
compile_error!(concat!("Invalid call fn name: `", stringify!($ident),
|
||||
"`, name is reserved and doesn't match expected signature, please refer to `decl_module!`",
|
||||
" documentation to see the appropriate usage, or rename it to an unreserved keyword."));
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
// Do not complain about unused `dispatch` and `dispatch_aux`.
|
||||
#[allow(dead_code)]
|
||||
|
||||
Reference in New Issue
Block a user