Skip to content

Commit

Permalink
[Deprecation] Remove the deprecated Store trait (paritytech#3532)
Browse files Browse the repository at this point in the history
# Description

*Removes the deprecated `trait Store` feature from the code base*

Fixes paritytech#222

---------

Co-authored-by: Dónal Murray <donalm@seadanda.dev>
  • Loading branch information
philoniare and seadanda committed Mar 11, 2024
1 parent 71b2054 commit dba40fc
Show file tree
Hide file tree
Showing 14 changed files with 5 additions and 276 deletions.
10 changes: 0 additions & 10 deletions substrate/frame/support/procedural/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,16 +858,6 @@ pub fn disable_frame_system_supertrait_check(_: TokenStream, _: TokenStream) ->
pallet_macro_stub()
}

///
/// ---
///
/// Rust-Analyzer Users: Documentation for this macro can be found at
/// `frame_support::pallet_macros::generate_store`.
#[proc_macro_attribute]
pub fn generate_store(_: TokenStream, _: TokenStream) -> TokenStream {
pallet_macro_stub()
}

///
/// ---
///
Expand Down
3 changes: 0 additions & 3 deletions substrate/frame/support/procedural/src/pallet/expand/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ mod instances;
mod origin;
mod pallet_struct;
mod storage;
mod store_trait;
mod tasks;
mod tt_default_parts;
mod type_value;
Expand Down Expand Up @@ -68,7 +67,6 @@ pub fn expand(mut def: Def) -> proc_macro2::TokenStream {
let storages = storage::expand_storages(&mut def);
let inherents = inherent::expand_inherents(&mut def);
let instances = instances::expand_instances(&mut def);
let store_trait = store_trait::expand_store_trait(&mut def);
let hooks = hooks::expand_hooks(&mut def);
let genesis_build = genesis_build::expand_genesis_build(&mut def);
let genesis_config = genesis_config::expand_genesis_config(&mut def);
Expand Down Expand Up @@ -110,7 +108,6 @@ storage item. Otherwise, all storage items are listed among [*Type Definitions*]
#storages
#inherents
#instances
#store_trait
#hooks
#genesis_build
#genesis_config
Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions substrate/frame/support/procedural/src/pallet/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,6 @@ mod keyword {
syn::custom_keyword!(validate_unsigned);
syn::custom_keyword!(type_value);
syn::custom_keyword!(pallet);
syn::custom_keyword!(generate_store);
syn::custom_keyword!(Store);
syn::custom_keyword!(extra_constants);
syn::custom_keyword!(composite_enum);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ use syn::spanned::Spanned;
mod keyword {
syn::custom_keyword!(pallet);
syn::custom_keyword!(Pallet);
syn::custom_keyword!(generate_store);
syn::custom_keyword!(without_storage_info);
syn::custom_keyword!(storage_version);
syn::custom_keyword!(Store);
}

/// Definition of the pallet pallet.
Expand All @@ -37,8 +35,6 @@ pub struct PalletStructDef {
pub instances: Vec<helper::InstanceUsage>,
/// The keyword Pallet used (contains span).
pub pallet: keyword::Pallet,
/// Whether the trait `Store` must be generated.
pub store: Option<(syn::Visibility, keyword::Store, proc_macro2::Span)>,
/// The span of the pallet::pallet attribute.
pub attr_span: proc_macro2::Span,
/// Whether to specify the storages max encoded len when implementing `StorageInfoTrait`.
Expand All @@ -49,21 +45,17 @@ pub struct PalletStructDef {
}

/// Parse for one variant of:
/// * `#[pallet::generate_store($vis trait Store)]`
/// * `#[pallet::without_storage_info]`
/// * `#[pallet::storage_version(STORAGE_VERSION)]`
pub enum PalletStructAttr {
GenerateStore { span: proc_macro2::Span, vis: syn::Visibility, keyword: keyword::Store },
WithoutStorageInfoTrait(proc_macro2::Span),
StorageVersion { storage_version: syn::Path, span: proc_macro2::Span },
}

impl PalletStructAttr {
fn span(&self) -> proc_macro2::Span {
match self {
Self::GenerateStore { span, .. } |
Self::WithoutStorageInfoTrait(span) |
Self::StorageVersion { span, .. } => *span,
Self::WithoutStorageInfoTrait(span) | Self::StorageVersion { span, .. } => *span,
}
}
}
Expand All @@ -77,16 +69,7 @@ impl syn::parse::Parse for PalletStructAttr {
content.parse::<syn::Token![::]>()?;

let lookahead = content.lookahead1();
if lookahead.peek(keyword::generate_store) {
content.parse::<keyword::generate_store>()?;
let generate_content;
syn::parenthesized!(generate_content in content);
let vis = generate_content.parse::<syn::Visibility>()?;
generate_content.parse::<syn::Token![trait]>()?;
let keyword = generate_content.parse::<keyword::Store>()?;
let span = content.span();
Ok(Self::GenerateStore { vis, keyword, span })
} else if lookahead.peek(keyword::without_storage_info) {
if lookahead.peek(keyword::without_storage_info) {
let span = content.parse::<keyword::without_storage_info>()?.span();
Ok(Self::WithoutStorageInfoTrait(span))
} else if lookahead.peek(keyword::storage_version) {
Expand Down Expand Up @@ -116,16 +99,12 @@ impl PalletStructDef {
return Err(syn::Error::new(item.span(), msg))
};

let mut store = None;
let mut without_storage_info = None;
let mut storage_version_found = None;

let struct_attrs: Vec<PalletStructAttr> = helper::take_item_pallet_attrs(&mut item.attrs)?;
for attr in struct_attrs {
match attr {
PalletStructAttr::GenerateStore { vis, keyword, span } if store.is_none() => {
store = Some((vis, keyword, span));
},
PalletStructAttr::WithoutStorageInfoTrait(span)
if without_storage_info.is_none() =>
{
Expand Down Expand Up @@ -162,7 +141,6 @@ impl PalletStructDef {
index,
instances,
pallet,
store,
attr_span,
without_storage_info,
storage_version: storage_version_found,
Expand Down
24 changes: 2 additions & 22 deletions substrate/frame/support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ pub use frame_support_procedural::crate_to_crate_version;
#[macro_export]
macro_rules! fail {
( $y:expr ) => {{
return Err($y.into())
return Err($y.into());
}};
}

Expand Down Expand Up @@ -949,7 +949,7 @@ pub mod pallet_prelude {
/// pub trait Config: frame_system::Config {}
/// }
/// ```
///
//
/// I.e. a regular struct definition named `Pallet`, with generic T and no where clause.
///
/// ## Macro expansion:
Expand Down Expand Up @@ -1341,26 +1341,6 @@ pub mod pallet_macros {
/// See [`pallet::storage`](`frame_support::pallet_macros::storage`) for more info.
pub use frame_support_procedural::getter;

/// Allows generating the `Store` trait for all storages.
///
/// DEPRECATED: Will be removed, do not use.
/// See <https://github.com/paritytech/substrate/pull/13535> for more details.
///
/// To generate a `Store` trait associating all storages, annotate your `Pallet` struct
/// with the attribute `#[pallet::generate_store($vis trait Store)]`, e.g.:
///
/// ```ignore
/// #[pallet::pallet]
/// #[pallet::generate_store(pub(super) trait Store)]
/// pub struct Pallet<T>(_);
/// ```
/// More precisely, the `Store` trait contains an associated type for each storage. It is
/// implemented for `Pallet` allowing access to the storage from pallet struct.
///
/// Thus when defining a storage named `Foo`, it can later be accessed from `Pallet` using
/// `<Pallet as Store>::Foo`.
pub use frame_support_procedural::generate_store;

/// Defines constants that are added to the constant field of
/// [`PalletMetadata`](frame_metadata::v15::PalletMetadata) struct for this pallet.
///
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: expected one of: `generate_store`, `without_storage_info`, `storage_version`
error: expected `without_storage_info` or `storage_version`
--> tests/pallet_ui/pallet_struct_invalid_attr.rs:24:12
|
24 | #[pallet::generate_storage_info] // invalid
Expand Down

This file was deleted.

Loading

0 comments on commit dba40fc

Please sign in to comment.