generate_storage_alias: Rewrite as proc macro attribute (#11387)

* generate_storage_alias: Rewrite as proc macro attribute

This rewrites the `generate_storage_alias!` declarative macro as proc-macro attribute. While doing
this the name is changed to `storage_alias`. The prefix can now also be the name of a pallet. This
makes storage aliases work in migrations for all kind of chains and not just for the ones that use
predefined prefixes.

* Fix compilation and FMT

* Moare fixes

* 🤦

* ......

* Rework the syntax and support instancing

* FMT

* Prefix variants with `Storage`

* Make it compile

* Fix where clause on rust stable
This commit is contained in:
Bastian Köcher
2022-05-18 00:45:56 +02:00
committed by GitHub
parent 27f08fec3a
commit 74428fa8ac
21 changed files with 884 additions and 379 deletions
@@ -31,6 +31,7 @@ mod pallet;
mod pallet_error;
mod partial_eq_no_bound;
mod storage;
mod storage_alias;
mod transactional;
mod tt_macro;
@@ -575,3 +576,10 @@ pub fn derive_pallet_error(input: TokenStream) -> TokenStream {
pub fn __create_tt_macro(input: TokenStream) -> TokenStream {
tt_macro::create_tt_return_macro(input)
}
#[proc_macro_attribute]
pub fn storage_alias(_: TokenStream, input: TokenStream) -> TokenStream {
storage_alias::storage_alias(input.into())
.unwrap_or_else(|r| r.into_compile_error())
.into()
}