Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
construct_runtime!: Support parsing struct Runtime (#11932)
Browse files Browse the repository at this point in the history
* construct_runtime!: Support parsing `struct Runtime`

* FMT
  • Loading branch information
bkchr authored Jul 29, 2022
1 parent 3ca8a42 commit 479c84c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,11 @@ impl pallet_template::Config for Runtime {

// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub enum Runtime where
pub struct Runtime
where
Block = Block,
NodeBlock = opaque::Block,
UncheckedExtrinsic = UncheckedExtrinsic
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system,
RandomnessCollectiveFlip: pallet_randomness_collective_flip,
Expand Down
2 changes: 1 addition & 1 deletion frame/balances/src/tests_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;

frame_support::construct_runtime!(
pub enum Test where
pub struct Test where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
Expand Down
9 changes: 8 additions & 1 deletion frame/support/procedural/src/construct_runtime/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ pub struct ExplicitRuntimeDeclaration {
impl Parse for RuntimeDeclaration {
fn parse(input: ParseStream) -> Result<Self> {
input.parse::<Token![pub]>()?;
input.parse::<Token![enum]>()?;

// Support either `enum` or `struct`.
if input.peek(Token![struct]) {
input.parse::<Token![struct]>()?;
} else {
input.parse::<Token![enum]>()?;
}

let name = input.parse::<syn::Ident>()?;
let where_section = input.parse()?;
let pallets =
Expand Down

0 comments on commit 479c84c

Please sign in to comment.