storage-alias: Check that prefix is not an underscore (#11704)

Besides that it also adds some UI tests.
This commit is contained in:
Bastian Köcher
2022-06-19 19:56:36 +02:00
committed by GitHub
parent eba0396182
commit ef56c17a5e
8 changed files with 63 additions and 0 deletions
@@ -512,6 +512,10 @@ fn generate_storage_instance(
prefix_generics: Option<&TypeGenerics>,
visibility: &Visibility,
) -> Result<StorageInstance> {
if let Some(ident) = prefix.get_ident().filter(|i| *i == "_") {
return Err(Error::new(ident.span(), "`_` is not allowed as prefix by `storage_alias`."))
}
let (pallet_prefix, impl_generics, type_generics) =
if let Some((prefix_generics, storage_generics)) =
prefix_generics.and_then(|p| storage_generics.map(|s| (p, s)))