This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Emit error when Config part is imported but without the std feature #9225
Merged
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a25390d
Emit error when Config part is imported but without the std feature
KiChjang 0e4c7f1
Add UI test for missing std feature on GenesisConfig
KiChjang ff254ab
Update frame/support/test/Cargo.toml
KiChjang d6ee521
Remove unused imports
KiChjang a87029c
Unify all dummy party checker macros
KiChjang 10b528a
Fix
KiChjang c915d75
Dispaly pallet_path::GenesisConfig instead of PalletConfig in error m…
KiChjang f74127e
Revert changes to construct_runtime_ui.rs
KiChjang b7fd27d
Add additional parameter for dummy part checker macro
KiChjang ca91345
Apply suggestions from code review
gui1117 c63bfbe
Merge remote-tracking branch 'origin/master' into kckyeung/error-on-g…
gui1117 8f8c326
fix master merge: update version
gui1117 6fb619d
update Cargo.lock
gui1117 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| [package] | ||
| name = "frame-support-test-pallet" | ||
| version = "3.0.0" | ||
|
gui1117 marked this conversation as resolved.
Outdated
|
||
| authors = ["Parity Technologies <admin@parity.io>"] | ||
| edition = "2018" | ||
| license = "Apache-2.0" | ||
| publish = false | ||
| homepage = "https://substrate.dev" | ||
| repository = "https://github.com/paritytech/substrate/" | ||
|
|
||
| [package.metadata.docs.rs] | ||
| targets = ["x86_64-unknown-linux-gnu"] | ||
|
|
||
| [dependencies] | ||
| codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] } | ||
| sp-io = { version = "3.0.0", path = "../../../../primitives/io", default-features = false } | ||
| sp-runtime = { version = "3.0.0", default-features = false, path = "../../../../primitives/runtime" } | ||
| sp-std = { version = "3.0.0", default-features = false, path = "../../../../primitives/std" } | ||
| frame-support = { version = "3.0.0", default-features = false, path = "../../" } | ||
|
gui1117 marked this conversation as resolved.
Outdated
|
||
| frame-system = { version = "3.0.0", default-features = false, path = "../../../system" } | ||
|
gui1117 marked this conversation as resolved.
Outdated
|
||
|
|
||
| [features] | ||
| default = ["std"] | ||
| std = [ | ||
| "codec/std", | ||
| "frame-support/std", | ||
| "frame-system/std", | ||
| "sp-io/std", | ||
| "sp-std/std", | ||
| "sp-runtime/std", | ||
| ] | ||
|
KiChjang marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // This file is part of Substrate. | ||
|
|
||
| // Copyright (C) 2021 Parity Technologies (UK) Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| pub use pallet::*; | ||
|
|
||
| #[frame_support::pallet] | ||
| pub mod pallet { | ||
| #[allow(unused_imports)] | ||
| use frame_support::pallet_prelude::*; | ||
| #[allow(unused_imports)] | ||
| use frame_system::pallet_prelude::*; | ||
|
|
||
| #[pallet::pallet] | ||
| pub struct Pallet<T>(_); | ||
|
|
||
| #[pallet::config] | ||
| pub trait Config: frame_system::Config {} | ||
|
|
||
| #[pallet::genesis_config] | ||
| pub struct GenesisConfig {} | ||
|
|
||
| #[cfg(feature = "std")] | ||
| impl Default for GenesisConfig { | ||
| fn default() -> Self { | ||
| Self {} | ||
| } | ||
| } | ||
|
|
||
| #[pallet::genesis_build] | ||
| impl<T: Config> GenesisBuild<T> for GenesisConfig { | ||
| fn build(&self) {} | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| use frame_support::construct_runtime; | ||
| use sp_runtime::{generic, traits::BlakeTwo256}; | ||
| use sp_core::sr25519; | ||
|
|
||
| pub type Signature = sr25519::Signature; | ||
| pub type BlockNumber = u64; | ||
| pub type Header = generic::Header<BlockNumber, BlakeTwo256>; | ||
| pub type Block = generic::Block<Header, UncheckedExtrinsic>; | ||
| pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<u32, Call, Signature, ()>; | ||
|
|
||
| impl test_pallet::Config for Runtime {} | ||
|
|
||
| construct_runtime! { | ||
| pub enum Runtime where | ||
| Block = Block, | ||
| NodeBlock = Block, | ||
| UncheckedExtrinsic = UncheckedExtrinsic | ||
| { | ||
| System: system::{Pallet, Call, Storage, Config, Event<T>}, | ||
| Pallet: test_pallet::{Pallet, Config}, | ||
| } | ||
| } | ||
|
|
||
| fn main() {} |
66 changes: 66 additions & 0 deletions
66
frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| error: `Pallet` does not have the std feature enabled, this will cause the `PalletConfig` type to be undefined. | ||
|
KiChjang marked this conversation as resolved.
Outdated
|
||
| --> $DIR/no_std_genesis_config.rs:13:1 | ||
| | | ||
| 13 | / construct_runtime! { | ||
| 14 | | pub enum Runtime where | ||
| 15 | | Block = Block, | ||
| 16 | | NodeBlock = Block, | ||
| ... | | ||
| 21 | | } | ||
| 22 | | } | ||
| | |_^ | ||
| | | ||
| = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
|
||
| error[E0433]: failed to resolve: use of undeclared crate or module `system` | ||
| --> $DIR/no_std_genesis_config.rs:19:11 | ||
| | | ||
| 19 | System: system::{Pallet, Call, Storage, Config, Event<T>}, | ||
| | ^^^^^^ use of undeclared crate or module `system` | ||
|
|
||
| error[E0433]: failed to resolve: use of undeclared crate or module `system` | ||
| --> $DIR/no_std_genesis_config.rs:13:1 | ||
| | | ||
| 13 | / construct_runtime! { | ||
| 14 | | pub enum Runtime where | ||
| 15 | | Block = Block, | ||
| 16 | | NodeBlock = Block, | ||
| ... | | ||
| 21 | | } | ||
| 22 | | } | ||
| | |_^ not found in `system` | ||
| | | ||
| = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
| help: consider importing this enum | ||
| | | ||
| 1 | use frame_system::RawOrigin; | ||
| | | ||
|
|
||
| error[E0412]: cannot find type `GenesisConfig` in crate `test_pallet` | ||
| --> $DIR/no_std_genesis_config.rs:13:1 | ||
| | | ||
| 13 | / construct_runtime! { | ||
| 14 | | pub enum Runtime where | ||
| 15 | | Block = Block, | ||
| 16 | | NodeBlock = Block, | ||
| ... | | ||
| 21 | | } | ||
| 22 | | } | ||
| | |_^ not found in `test_pallet` | ||
| | | ||
| = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
| help: consider importing this struct | ||
| | | ||
| 1 | use frame_system::GenesisConfig; | ||
| | | ||
|
|
||
| error[E0277]: the trait bound `Runtime: frame_system::pallet::Config` is not satisfied | ||
| --> $DIR/no_std_genesis_config.rs:11:6 | ||
| | | ||
| 11 | impl test_pallet::Config for Runtime {} | ||
| | ^^^^^^^^^^^^^^^^^^^ the trait `frame_system::pallet::Config` is not implemented for `Runtime` | ||
| | | ||
| ::: $WORKSPACE/frame/support/test/pallet/src/lib.rs | ||
| | | ||
| | pub trait Config: frame_system::Config {} | ||
| | -------------------- required by this bound in `Config` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.