diff --git a/frame/support/procedural/src/storage_alias.rs b/frame/support/procedural/src/storage_alias.rs index c44ca586eea94..adec995016653 100644 --- a/frame/support/procedural/src/storage_alias.rs +++ b/frame/support/procedural/src/storage_alias.rs @@ -412,9 +412,9 @@ struct Input { _type: Token![type], storage_name: Ident, storage_generics: Option, + where_clause: Option, _equal: Token![=], storage_type: StorageType, - where_clause: Option, _semicolon: Token![;], } @@ -426,17 +426,26 @@ impl Parse for Input { let storage_name = input.parse()?; let lookahead = input.lookahead1(); - let (storage_generics, _equal) = if lookahead.peek(Token![<]) { - (Some(input.parse()?), input.parse()?) + let storage_generics = if lookahead.peek(Token![<]) { + Some(input.parse()?) } else if lookahead.peek(Token![=]) { - (None, input.parse()?) + None } else { return Err(lookahead.error()) }; - let storage_type = input.parse()?; + let lookahead = input.lookahead1(); + let where_clause = if lookahead.peek(Token![where]) { + Some(input.parse()?) + } else if lookahead.peek(Token![=]) { + None + } else { + return Err(lookahead.error()) + }; + + let _equal = input.parse()?; - let where_clause = input.parse()?; + let storage_type = input.parse()?; let _semicolon = input.parse()?; diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 6463e4f9317c1..935dfd5ffeb33 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -1640,9 +1640,10 @@ fn assert_type_all_pallets_without_system_reversed_is_correct() { #[test] fn test_storage_alias() { #[frame_support::storage_alias] - type Value = - StorageValue, u32, ValueQuery> - where ::AccountId: From + SomeAssociation1; + type Value + where + ::AccountId: From + SomeAssociation1, + = StorageValue, u32, ValueQuery>; TestExternalities::default().execute_with(|| { pallet::Value::::put(10);