Skip to content

Commit 7cd0520

Browse files
bkchrark0f
authored andcommitted
construct_runtime!: Support parsing struct Runtime (paritytech#11932)
* construct_runtime!: Support parsing `struct Runtime` * FMT
1 parent 1cfe86c commit 7cd0520

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

bin/node-template/runtime/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,11 @@ impl pallet_template::Config for Runtime {
272272

273273
// Create the runtime by composing the FRAME pallets that were previously configured.
274274
construct_runtime!(
275-
pub enum Runtime where
275+
pub struct Runtime
276+
where
276277
Block = Block,
277278
NodeBlock = opaque::Block,
278-
UncheckedExtrinsic = UncheckedExtrinsic
279+
UncheckedExtrinsic = UncheckedExtrinsic,
279280
{
280281
System: frame_system,
281282
RandomnessCollectiveFlip: pallet_randomness_collective_flip,

frame/balances/src/tests_local.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
3434
type Block = frame_system::mocking::MockBlock<Test>;
3535

3636
frame_support::construct_runtime!(
37-
pub enum Test where
37+
pub struct Test where
3838
Block = Block,
3939
NodeBlock = Block,
4040
UncheckedExtrinsic = UncheckedExtrinsic,

frame/support/procedural/src/construct_runtime/parse.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,14 @@ pub struct ExplicitRuntimeDeclaration {
7373
impl Parse for RuntimeDeclaration {
7474
fn parse(input: ParseStream) -> Result<Self> {
7575
input.parse::<Token![pub]>()?;
76-
input.parse::<Token![enum]>()?;
76+
77+
// Support either `enum` or `struct`.
78+
if input.peek(Token![struct]) {
79+
input.parse::<Token![struct]>()?;
80+
} else {
81+
input.parse::<Token![enum]>()?;
82+
}
83+
7784
let name = input.parse::<syn::Ident>()?;
7885
let where_section = input.parse()?;
7986
let pallets =

0 commit comments

Comments
 (0)