Allow construct_runtime to take cfg attributes for pallets (#11818)

* Allow construct_runtime to take cfg attributes for pallets

* cargo fmt

* Remove commented out code

* Fixes

* cargo fmt

* Remove inaccurate comments

* Fix typo

* Properly reverse pallets

* Fixes

* cargo fmt

* Add missing newlines
This commit is contained in:
Keith Yeung authored and GitHub committed 2022-08-25 08:56:18 +00:00
1 parent edc8f7b409
commit 948af11977
20 files changed
+480 -85

No files matched your search

@@ -0,0 +1,14 @@
use frame_support::construct_runtime;
construct_runtime! {
pub enum Runtime where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
#[cfg(test)]
System: frame_system::{Pallet, Call, Storage, Config, Event<T>},
}
}
fn main() {}
@@ -0,0 +1,5 @@
error: `System` pallet declaration is feature gated, please remove any `#[cfg]` attributes
--> tests/construct_runtime_ui/feature_gated_system_pallet.rs:10:3
|
10 | System: frame_system::{Pallet, Call, Storage, Config, Event<T>},
| ^^^^^^
@@ -0,0 +1,15 @@
use frame_support::construct_runtime;
construct_runtime! {
pub enum Runtime where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: system::{Pallet},
#[cfg(feature = 1)]
Balance: balances::{Config, Call},
}
}
fn main() {}
@@ -0,0 +1,6 @@
error: feature = 1
^ expected one of `<key>`, `all`, `any`, `not` here
--> tests/construct_runtime_ui/invalid_meta_literal.rs:10:3
|
10 | #[cfg(feature = 1)]
| ^
@@ -0,0 +1,15 @@
use frame_support::construct_runtime;
construct_runtime! {
pub enum Runtime where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: system::{Pallet},
#[cfg(feature(test))]
Balance: balances::{Config, Call},
}
}
fn main() {}
@@ -0,0 +1,6 @@
error: feature(test)
^ expected one of `=`, `,`, `)` here
--> tests/construct_runtime_ui/unsupported_meta_structure.rs:10:3
|
10 | #[cfg(feature(test))]
| ^
@@ -0,0 +1,15 @@
use frame_support::construct_runtime;
construct_runtime! {
pub enum Runtime where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: system::{Pallet},
#[attr]
Balance: balances::{Config, Call},
}
}
fn main() {}
@@ -0,0 +1,5 @@
error: Unsupported attribute, only #[cfg] is supported on pallet declarations in `construct_runtime`
--> tests/construct_runtime_ui/unsupported_pallet_attr.rs:10:3
|
10 | #[attr]
| ^