Emit error when Config part is imported but without the std feature (#9225)

* Emit error when Config part is imported but without the std feature

* Add UI test for missing std feature on GenesisConfig

* Update frame/support/test/Cargo.toml

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Remove unused imports

* Unify all dummy party checker macros

* Fix

* Dispaly pallet_path::GenesisConfig instead of PalletConfig in error message

* Revert changes to construct_runtime_ui.rs

* Add additional parameter for dummy part checker macro

* Apply suggestions from code review

* fix master merge: update version

* update Cargo.lock

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
Keith Yeung
2021-07-16 07:07:19 -07:00
committed by GitHub
parent 1e8035a273
commit 3ce2bd3eec
9 changed files with 268 additions and 89 deletions
@@ -9,96 +9,54 @@ pub fn generate_dummy_part_checker(input: TokenStream) -> TokenStream {
let count = COUNTER.with(|counter| counter.borrow_mut().inc());
let genesis_config_macro_ident = syn::Ident::new(
&format!("__is_genesis_config_defined_{}", count),
proc_macro2::Span::call_site(),
);
let event_macro_ident = syn::Ident::new(
&format!("__is_event_part_defined_{}", count),
proc_macro2::Span::call_site(),
);
let inherent_macro_ident = syn::Ident::new(
&format!("__is_inherent_part_defined_{}", count),
proc_macro2::Span::call_site(),
);
let validate_unsigned_macro_ident = syn::Ident::new(
&format!("__is_validate_unsigned_part_defined_{}", count),
proc_macro2::Span::call_site(),
);
let call_macro_ident = syn::Ident::new(
&format!("__is_call_part_defined_{}", count),
proc_macro2::Span::call_site(),
);
let origin_macro_ident = syn::Ident::new(
&format!("__is_origin_part_defined_{}", count),
let no_op_macro_ident = syn::Ident::new(
&format!("__dummy_part_checker_{}", count),
proc_macro2::Span::call_site(),
);
quote::quote!(
#[macro_export]
#[doc(hidden)]
macro_rules! #no_op_macro_ident {
( $( $tt:tt )* ) => {};
}
#[doc(hidden)]
pub mod __substrate_genesis_config_check {
#[macro_export]
#[doc(hidden)]
macro_rules! #genesis_config_macro_ident {
($pallet_name:ident) => {};
}
pub use #no_op_macro_ident as is_genesis_config_defined;
#[doc(hidden)]
pub use #genesis_config_macro_ident as is_genesis_config_defined;
pub use #no_op_macro_ident as is_std_enabled_for_genesis;
}
#[doc(hidden)]
pub mod __substrate_event_check {
#[macro_export]
#[doc(hidden)]
macro_rules! #event_macro_ident {
($pallet_name:ident) => {};
}
#[doc(hidden)]
pub use #event_macro_ident as is_event_part_defined;
pub use #no_op_macro_ident as is_event_part_defined;
}
#[doc(hidden)]
pub mod __substrate_inherent_check {
#[macro_export]
#[doc(hidden)]
macro_rules! #inherent_macro_ident {
($pallet_name:ident) => {};
}
#[doc(hidden)]
pub use #inherent_macro_ident as is_inherent_part_defined;
pub use #no_op_macro_ident as is_inherent_part_defined;
}
#[doc(hidden)]
pub mod __substrate_validate_unsigned_check {
#[macro_export]
#[doc(hidden)]
macro_rules! #validate_unsigned_macro_ident {
($pallet_name:ident) => {};
}
#[doc(hidden)]
pub use #validate_unsigned_macro_ident as is_validate_unsigned_part_defined;
pub use #no_op_macro_ident as is_validate_unsigned_part_defined;
}
#[doc(hidden)]
pub mod __substrate_call_check {
#[macro_export]
#[doc(hidden)]
macro_rules! #call_macro_ident {
($pallet_name:ident) => {};
}
#[doc(hidden)]
pub use #call_macro_ident as is_call_part_defined;
pub use #no_op_macro_ident as is_call_part_defined;
}
#[doc(hidden)]
pub mod __substrate_origin_check {
#[macro_export]
#[doc(hidden)]
macro_rules! #origin_macro_ident {
($pallet_name:ident) => {};
}
#[doc(hidden)]
pub use #origin_macro_ident as is_origin_part_defined;
pub use #no_op_macro_ident as is_origin_part_defined;
}
).into()
}