Fix parameter_types! macro (#8594)

Make it work with different kinds of parameter types when
`static` is one of them.
This commit is contained in:
Bastian Köcher
2021-04-12 19:37:35 +02:00
committed by GitHub
parent 29864b255c
commit 59b900bae3
+14 -8
View File
@@ -379,21 +379,20 @@ macro_rules! parameter_types {
}
};
(
$(
$( #[ $attr:meta ] )*
$vis:vis static $name:ident: $type:ty = $value:expr;
)*
$( #[ $attr:meta ] )*
$vis:vis static $name:ident: $type:ty = $value:expr;
$( $rest:tt )*
) => (
$crate::parameter_types_impl_thread_local!(
$(
$( #[ $attr ] )*
$vis static $name: $type = $value;
)*
$( #[ $attr ] )*
$vis static $name: $type = $value;
);
$crate::parameter_types!( $( $rest )* );
);
}
#[cfg(not(feature = "std"))]
#[doc(inline)]
#[macro_export]
macro_rules! parameter_types_impl_thread_local {
( $( $any:tt )* ) => {
@@ -402,6 +401,7 @@ macro_rules! parameter_types_impl_thread_local {
}
#[cfg(feature = "std")]
#[doc(inline)]
#[macro_export]
macro_rules! parameter_types_impl_thread_local {
(
@@ -1217,6 +1217,12 @@ pub mod tests {
assert_eq!(300, StorageParameter::get());
})
}
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub static Members: Vec<u64> = vec![];
pub const Foo: Option<u64> = None;
}
}
/// Prelude to be used alongside pallet macro, for ease of use.