Skip to content

Commit

Permalink
Remove #[pallet::generate_storage_info] from docs (paritytech#14116)
Browse files Browse the repository at this point in the history
* Fix docs

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* Add UI test

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

---------

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
  • Loading branch information
ggwpez authored and nathanwhit committed Jul 19, 2023
1 parent 688314c commit 67d3978
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 40 deletions.
18 changes: 0 additions & 18 deletions frame/support/procedural/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(_);
/// ```
///
/// 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:
Expand Down
25 changes: 3 additions & 22 deletions frame/support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<T>(_);
/// ```
///
/// 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
Expand Down Expand Up @@ -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,
};
}

Expand Down
15 changes: 15 additions & 0 deletions frame/support/test/tests/pallet_ui/pallet_struct_invalid_attr.rs
Original file line number Diff line number Diff line change
@@ -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<T>(_);

#[pallet::call]
impl<T: Config> Pallet<T> {}
}

fn main() {
}
Original file line number Diff line number Diff line change
@@ -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
| ^^^^^^^^^^^^^^^^^^^^^

0 comments on commit 67d3978

Please sign in to comment.