From 67d39788ad98649bdedc8b8c1acf2f15689578a0 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Wed, 10 May 2023 22:29:00 +0200 Subject: [PATCH] Remove `#[pallet::generate_storage_info]` from docs (#14116) * Fix docs Signed-off-by: Oliver Tale-Yazdi * Add UI test Signed-off-by: Oliver Tale-Yazdi --------- Signed-off-by: Oliver Tale-Yazdi --- frame/support/procedural/src/lib.rs | 18 ------------- frame/support/src/lib.rs | 25 +++---------------- .../pallet_ui/pallet_struct_invalid_attr.rs | 15 +++++++++++ .../pallet_struct_invalid_attr.stderr | 5 ++++ 4 files changed, 23 insertions(+), 40 deletions(-) create mode 100644 frame/support/test/tests/pallet_ui/pallet_struct_invalid_attr.rs create mode 100644 frame/support/test/tests/pallet_ui/pallet_struct_invalid_attr.stderr diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index abfa21b331b0e..895b09a17e083 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -869,24 +869,6 @@ pub fn generate_store(_: TokenStream, _: TokenStream) -> TokenStream { pallet_macro_stub() } -/// To generate the full storage info (used for PoV calculation) use the attribute -/// `#[pallet::generate_storage_info]`, e.g.: -/// -/// ```ignore -/// #[pallet::pallet] -/// #[pallet::generate_storage_info] -/// pub struct Pallet(_); -/// ``` -/// -/// This requires all storage items to implement the trait `StorageInfoTrait`, thus all keys -/// and value types must be bound by `MaxEncodedLen`. Individual storages can opt-out from this -/// constraint by using [`#[pallet::unbounded]`](`macro@unbounded`) (see -/// [`#[pallet::storage]`](`macro@storage`) for more info). -#[proc_macro_attribute] -pub fn generate_storage_info(_: TokenStream, _: TokenStream) -> TokenStream { - pallet_macro_stub() -} - /// Because the `pallet::pallet` macro implements `GetStorageVersion`, the current storage /// version needs to be communicated to the macro. This can be done by using the /// `pallet::storage_version` attribute: diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 138b7b55bf0eb..3cd8378be45d1 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -1597,7 +1597,6 @@ pub mod pallet_prelude { /// * [`pallet::constant`](#palletconstant) /// * [`pallet::disable_frame_system_supertrait_check`](#disable_supertrait_check) /// * [`pallet::generate_store($vis trait Store)`](#palletgenerate_storevis-trait-store) -/// * [`pallet::generate_storage_info`](#palletgenerate_storage_info) /// * [`pallet::storage_version`](#palletstorage_version) /// * [`pallet::hooks`](#hooks-pallethooks-optional) /// * [`pallet::call`](#call-palletcall-optional) @@ -1801,24 +1800,6 @@ pub mod pallet_prelude { /// /// Also see [`pallet::generate_store`](`frame_support::pallet_macros::generate_store`). /// -/// # `pallet::generate_storage_info` -/// -/// To generate the full storage info (used for PoV calculation) use the attribute -/// `#[pallet::generate_storage_info]`, e.g.: -/// -/// ```ignore -/// #[pallet::pallet] -/// #[pallet::generate_storage_info] -/// pub struct Pallet(_); -/// ``` -/// -/// This requires all storage items to implement the trait [`traits::StorageInfoTrait`], thus -/// all keys and value types must be bound by [`pallet_prelude::MaxEncodedLen`]. Individual -/// storages can opt-out from this constraint by using `#[pallet::unbounded]` (see -/// `#[pallet::storage]` for more info). -/// -/// Also see [`pallet::generate_storage_info`](`frame_support::pallet_macros::generate_storage_info`) -/// /// # `pallet::storage_version` /// /// Because the [`pallet::pallet`](#pallet-struct-placeholder-palletpallet-mandatory) macro @@ -2903,9 +2884,9 @@ pub mod pallet_macros { pub use frame_support_procedural::{ call_index, compact, composite_enum, config, constant, disable_frame_system_supertrait_check, error, event, extra_constants, generate_deposit, - generate_storage_info, generate_store, genesis_build, genesis_config, getter, hooks, - inherent, origin, storage, storage_prefix, storage_version, type_value, unbounded, - validate_unsigned, weight, whitelist_storage, + generate_store, genesis_build, genesis_config, getter, hooks, inherent, origin, storage, + storage_prefix, storage_version, type_value, unbounded, validate_unsigned, weight, + whitelist_storage, }; } diff --git a/frame/support/test/tests/pallet_ui/pallet_struct_invalid_attr.rs b/frame/support/test/tests/pallet_ui/pallet_struct_invalid_attr.rs new file mode 100644 index 0000000000000..ac52e75a5f489 --- /dev/null +++ b/frame/support/test/tests/pallet_ui/pallet_struct_invalid_attr.rs @@ -0,0 +1,15 @@ +#[frame_support::pallet] +mod pallet { + #[pallet::config] + pub trait Config: frame_system::Config {} + + #[pallet::pallet] + #[pallet::generate_storage_info] // invalid + pub struct Pallet(_); + + #[pallet::call] + impl Pallet {} +} + +fn main() { +} diff --git a/frame/support/test/tests/pallet_ui/pallet_struct_invalid_attr.stderr b/frame/support/test/tests/pallet_ui/pallet_struct_invalid_attr.stderr new file mode 100644 index 0000000000000..301a73c000f07 --- /dev/null +++ b/frame/support/test/tests/pallet_ui/pallet_struct_invalid_attr.stderr @@ -0,0 +1,5 @@ +error: expected one of: `generate_store`, `without_storage_info`, `storage_version` + --> tests/pallet_ui/pallet_struct_invalid_attr.rs:7:12 + | +7 | #[pallet::generate_storage_info] // invalid + | ^^^^^^^^^^^^^^^^^^^^^