diff --git a/substrate/frame/support/procedural/src/construct_runtime/parse.rs b/substrate/frame/support/procedural/src/construct_runtime/parse.rs index ded77bed4c8e..532e032d0cb7 100644 --- a/substrate/frame/support/procedural/src/construct_runtime/parse.rs +++ b/substrate/frame/support/procedural/src/construct_runtime/parse.rs @@ -65,8 +65,6 @@ pub enum RuntimeDeclaration { /// Declaration of a runtime with some pallet with implicit declaration of parts. #[derive(Debug)] pub struct ImplicitRuntimeDeclaration { - pub name: Ident, - pub where_section: Option, pub pallets: Vec, } @@ -98,11 +96,7 @@ impl Parse for RuntimeDeclaration { match convert_pallets(pallets.content.inner.into_iter().collect())? { PalletsConversion::Implicit(pallets) => - Ok(RuntimeDeclaration::Implicit(ImplicitRuntimeDeclaration { - name, - where_section, - pallets, - })), + Ok(RuntimeDeclaration::Implicit(ImplicitRuntimeDeclaration { pallets })), PalletsConversion::Explicit(pallets) => Ok(RuntimeDeclaration::Explicit(ExplicitRuntimeDeclaration { name, @@ -124,9 +118,6 @@ impl Parse for RuntimeDeclaration { #[derive(Debug)] pub struct WhereSection { pub span: Span, - pub block: syn::TypePath, - pub node_block: syn::TypePath, - pub unchecked_extrinsic: syn::TypePath, } impl Parse for WhereSection { @@ -145,10 +136,9 @@ impl Parse for WhereSection { } input.parse::()?; } - let block = remove_kind(input, WhereKind::Block, &mut definitions)?.value; - let node_block = remove_kind(input, WhereKind::NodeBlock, &mut definitions)?.value; - let unchecked_extrinsic = - remove_kind(input, WhereKind::UncheckedExtrinsic, &mut definitions)?.value; + remove_kind(input, WhereKind::Block, &mut definitions)?; + remove_kind(input, WhereKind::NodeBlock, &mut definitions)?; + remove_kind(input, WhereKind::UncheckedExtrinsic, &mut definitions)?; if let Some(WhereDefinition { ref kind_span, ref kind, .. }) = definitions.first() { let msg = format!( "`{:?}` was declared above. Please use exactly one declaration for `{:?}`.", @@ -156,7 +146,7 @@ impl Parse for WhereSection { ); return Err(Error::new(*kind_span, msg)) } - Ok(Self { span: input.span(), block, node_block, unchecked_extrinsic }) + Ok(Self { span: input.span() }) } } @@ -171,7 +161,6 @@ pub enum WhereKind { pub struct WhereDefinition { pub kind_span: Span, pub kind: WhereKind, - pub value: syn::TypePath, } impl Parse for WhereDefinition { @@ -187,14 +176,10 @@ impl Parse for WhereDefinition { return Err(lookahead.error()) }; - Ok(Self { - kind_span, - kind, - value: { - let _: Token![=] = input.parse()?; - input.parse()? - }, - }) + let _: Token![=] = input.parse()?; + let _: syn::TypePath = input.parse()?; + + Ok(Self { kind_span, kind }) } } diff --git a/substrate/frame/support/procedural/src/pallet/expand/error.rs b/substrate/frame/support/procedural/src/pallet/expand/error.rs index 72fb6e923572..b921d66ff9e7 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/error.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/error.rs @@ -71,23 +71,25 @@ pub fn expand_error(def: &mut Def) -> proc_macro2::TokenStream { ) ); - let as_str_matches = error.variants.iter().map( - |VariantDef { ident: variant, field: field_ty, docs: _, cfg_attrs }| { - let variant_str = variant.to_string(); - let cfg_attrs = cfg_attrs.iter().map(|attr| attr.to_token_stream()); - match field_ty { - Some(VariantField { is_named: true }) => { - quote::quote_spanned!(error.attr_span => #( #cfg_attrs )* Self::#variant { .. } => #variant_str,) - }, - Some(VariantField { is_named: false }) => { - quote::quote_spanned!(error.attr_span => #( #cfg_attrs )* Self::#variant(..) => #variant_str,) - }, - None => { - quote::quote_spanned!(error.attr_span => #( #cfg_attrs )* Self::#variant => #variant_str,) - }, - } - }, - ); + let as_str_matches = + error + .variants + .iter() + .map(|VariantDef { ident: variant, field: field_ty, cfg_attrs }| { + let variant_str = variant.to_string(); + let cfg_attrs = cfg_attrs.iter().map(|attr| attr.to_token_stream()); + match field_ty { + Some(VariantField { is_named: true }) => { + quote::quote_spanned!(error.attr_span => #( #cfg_attrs )* Self::#variant { .. } => #variant_str,) + }, + Some(VariantField { is_named: false }) => { + quote::quote_spanned!(error.attr_span => #( #cfg_attrs )* Self::#variant(..) => #variant_str,) + }, + None => { + quote::quote_spanned!(error.attr_span => #( #cfg_attrs )* Self::#variant => #variant_str,) + }, + } + }); let error_item = { let item = &mut def.item.content.as_mut().expect("Checked by def parser").1[error.index]; diff --git a/substrate/frame/support/procedural/src/pallet/parse/composite.rs b/substrate/frame/support/procedural/src/pallet/parse/composite.rs index c3ac74846bf7..20fc30cd26b1 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/composite.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/composite.rs @@ -87,8 +87,6 @@ pub mod keyword { } pub struct CompositeDef { - /// The index of the CompositeDef item in the pallet module. - pub index: usize, /// The composite keyword used (contains span). pub composite_keyword: keyword::CompositeKeyword, /// Name of the associated type. @@ -104,7 +102,6 @@ pub struct CompositeDef { impl CompositeDef { pub fn try_from( attr_span: proc_macro2::Span, - index: usize, scrate: &syn::Path, item: &mut syn::Item, ) -> syn::Result { @@ -180,7 +177,6 @@ impl CompositeDef { syn::parse2::(item.ident.to_token_stream())?; Ok(CompositeDef { - index, composite_keyword, attr_span, generics: item.generics.clone(), diff --git a/substrate/frame/support/procedural/src/pallet/parse/config.rs b/substrate/frame/support/procedural/src/pallet/parse/config.rs index eaeaab247588..6febaac9ffa3 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/config.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/config.rs @@ -62,8 +62,6 @@ pub struct ConfigDef { pub has_event_type: bool, /// The where clause on trait definition but modified so `Self` is `T`. pub where_clause: Option, - /// The span of the pallet::config attribute. - pub attr_span: proc_macro2::Span, /// Whether a default sub-trait should be generated. /// /// Contains default sub-trait items (instantiated by `#[pallet::config(with_default)]`). @@ -325,7 +323,6 @@ pub fn replace_self_by_t(input: proc_macro2::TokenStream) -> proc_macro2::TokenS impl ConfigDef { pub fn try_from( frame_system: &syn::Path, - attr_span: proc_macro2::Span, index: usize, item: &mut syn::Item, enable_default: bool, @@ -484,7 +481,6 @@ impl ConfigDef { consts_metadata, has_event_type, where_clause, - attr_span, default_sub_trait, }) } diff --git a/substrate/frame/support/procedural/src/pallet/parse/error.rs b/substrate/frame/support/procedural/src/pallet/parse/error.rs index 362df8d7340c..bc4087a0ea76 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/error.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/error.rs @@ -16,7 +16,6 @@ // limitations under the License. use super::helper; -use frame_support_procedural_tools::get_doc_literals; use quote::ToTokens; use syn::{spanned::Spanned, Fields}; @@ -37,8 +36,6 @@ pub struct VariantDef { pub ident: syn::Ident, /// The variant field, if any. pub field: Option, - /// The variant doc literals. - pub docs: Vec, /// The `cfg` attributes. pub cfg_attrs: Vec, } @@ -101,12 +98,7 @@ impl ErrorDef { } let cfg_attrs: Vec = helper::get_item_cfg_attrs(&variant.attrs); - Ok(VariantDef { - ident: variant.ident.clone(), - field: field_ty, - docs: get_doc_literals(&variant.attrs), - cfg_attrs, - }) + Ok(VariantDef { ident: variant.ident.clone(), field: field_ty, cfg_attrs }) }) .collect::>()?; diff --git a/substrate/frame/support/procedural/src/pallet/parse/extra_constants.rs b/substrate/frame/support/procedural/src/pallet/parse/extra_constants.rs index 2ba6c44b7d15..12a373db180c 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/extra_constants.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/extra_constants.rs @@ -37,8 +37,6 @@ pub struct ExtraConstantsDef { pub where_clause: Option, /// A set of usage of instance, must be check for consistency with trait. pub instances: Vec, - /// The index of call item in pallet module. - pub index: usize, /// The extra constant defined. pub extra_constants: Vec, } @@ -77,7 +75,7 @@ impl syn::parse::Parse for ExtraConstAttr { } impl ExtraConstantsDef { - pub fn try_from(index: usize, item: &mut syn::Item) -> syn::Result { + pub fn try_from(item: &mut syn::Item) -> syn::Result { let item = if let syn::Item::Impl(item) = item { item } else { @@ -150,11 +148,6 @@ impl ExtraConstantsDef { }); } - Ok(Self { - index, - instances, - where_clause: item.generics.where_clause.clone(), - extra_constants, - }) + Ok(Self { instances, where_clause: item.generics.where_clause.clone(), extra_constants }) } } diff --git a/substrate/frame/support/procedural/src/pallet/parse/genesis_build.rs b/substrate/frame/support/procedural/src/pallet/parse/genesis_build.rs index d0e1d9ec998e..bc925a21c9c8 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/genesis_build.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/genesis_build.rs @@ -20,8 +20,6 @@ use syn::spanned::Spanned; /// Definition for pallet genesis build implementation. pub struct GenesisBuildDef { - /// The index of item in pallet module. - pub index: usize, /// A set of usage of instance, must be check for consistency with trait. pub instances: Option>, /// The where_clause used. @@ -31,11 +29,7 @@ pub struct GenesisBuildDef { } impl GenesisBuildDef { - pub fn try_from( - attr_span: proc_macro2::Span, - index: usize, - item: &mut syn::Item, - ) -> syn::Result { + pub fn try_from(attr_span: proc_macro2::Span, item: &mut syn::Item) -> syn::Result { let item = if let syn::Item::Impl(item) = item { item } else { @@ -56,6 +50,6 @@ impl GenesisBuildDef { let instances = helper::check_genesis_builder_usage(item_trait)?.map(|instances| vec![instances]); - Ok(Self { attr_span, index, instances, where_clause: item.generics.where_clause.clone() }) + Ok(Self { attr_span, instances, where_clause: item.generics.where_clause.clone() }) } } diff --git a/substrate/frame/support/procedural/src/pallet/parse/hooks.rs b/substrate/frame/support/procedural/src/pallet/parse/hooks.rs index 37d7d22f4b6b..07b51c8b91fa 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/hooks.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/hooks.rs @@ -20,8 +20,6 @@ use syn::spanned::Spanned; /// Implementation of the pallet hooks. pub struct HooksDef { - /// The index of item in pallet. - pub index: usize, /// A set of usage of instance, must be check for consistency with trait. pub instances: Vec, /// The where_clause used. @@ -33,11 +31,7 @@ pub struct HooksDef { } impl HooksDef { - pub fn try_from( - attr_span: proc_macro2::Span, - index: usize, - item: &mut syn::Item, - ) -> syn::Result { + pub fn try_from(attr_span: proc_macro2::Span, item: &mut syn::Item) -> syn::Result { let item = if let syn::Item::Impl(item) = item { item } else { @@ -77,7 +71,6 @@ impl HooksDef { Ok(Self { attr_span, - index, instances, has_runtime_upgrade, where_clause: item.generics.where_clause.clone(), diff --git a/substrate/frame/support/procedural/src/pallet/parse/inherent.rs b/substrate/frame/support/procedural/src/pallet/parse/inherent.rs index d8641691a40e..56ebe8e5df43 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/inherent.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/inherent.rs @@ -20,14 +20,12 @@ use syn::spanned::Spanned; /// The definition of the pallet inherent implementation. pub struct InherentDef { - /// The index of inherent item in pallet module. - pub index: usize, /// A set of usage of instance, must be check for consistency with trait. pub instances: Vec, } impl InherentDef { - pub fn try_from(index: usize, item: &mut syn::Item) -> syn::Result { + pub fn try_from(item: &mut syn::Item) -> syn::Result { let item = if let syn::Item::Impl(item) = item { item } else { @@ -55,6 +53,6 @@ impl InherentDef { helper::check_impl_gen(&item.generics, item.impl_token.span())?, ]; - Ok(InherentDef { index, instances }) + Ok(InherentDef { instances }) } } diff --git a/substrate/frame/support/procedural/src/pallet/parse/mod.rs b/substrate/frame/support/procedural/src/pallet/parse/mod.rs index 6e12774611dd..f55b166c7917 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/mod.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/mod.rs @@ -109,10 +109,9 @@ impl Def { let pallet_attr: Option = helper::take_first_item_pallet_attr(item)?; match pallet_attr { - Some(PalletAttr::Config(span, with_default)) if config.is_none() => + Some(PalletAttr::Config(_, with_default)) if config.is_none() => config = Some(config::ConfigDef::try_from( &frame_system, - span, index, item, with_default, @@ -122,7 +121,7 @@ impl Def { pallet_struct = Some(p); }, Some(PalletAttr::Hooks(span)) if hooks.is_none() => { - let m = hooks::HooksDef::try_from(span, index, item)?; + let m = hooks::HooksDef::try_from(span, item)?; hooks = Some(m); }, Some(PalletAttr::RuntimeCall(cw, span)) if call.is_none() => @@ -162,27 +161,27 @@ impl Def { genesis_config = Some(g); }, Some(PalletAttr::GenesisBuild(span)) if genesis_build.is_none() => { - let g = genesis_build::GenesisBuildDef::try_from(span, index, item)?; + let g = genesis_build::GenesisBuildDef::try_from(span, item)?; genesis_build = Some(g); }, Some(PalletAttr::RuntimeOrigin(_)) if origin.is_none() => - origin = Some(origin::OriginDef::try_from(index, item)?), + origin = Some(origin::OriginDef::try_from(item)?), Some(PalletAttr::Inherent(_)) if inherent.is_none() => - inherent = Some(inherent::InherentDef::try_from(index, item)?), + inherent = Some(inherent::InherentDef::try_from(item)?), Some(PalletAttr::Storage(span)) => storages.push(storage::StorageDef::try_from(span, index, item, dev_mode)?), Some(PalletAttr::ValidateUnsigned(_)) if validate_unsigned.is_none() => { - let v = validate_unsigned::ValidateUnsignedDef::try_from(index, item)?; + let v = validate_unsigned::ValidateUnsignedDef::try_from(item)?; validate_unsigned = Some(v); }, Some(PalletAttr::TypeValue(span)) => type_values.push(type_value::TypeValueDef::try_from(span, index, item)?), Some(PalletAttr::ExtraConstants(_)) => extra_constants = - Some(extra_constants::ExtraConstantsDef::try_from(index, item)?), + Some(extra_constants::ExtraConstantsDef::try_from(item)?), Some(PalletAttr::Composite(span)) => { let composite = - composite::CompositeDef::try_from(span, index, &frame_support, item)?; + composite::CompositeDef::try_from(span, &frame_support, item)?; if composites.iter().any(|def| { match (&def.composite_keyword, &composite.composite_keyword) { ( @@ -722,7 +721,6 @@ impl syn::parse::Parse for PalletAttr { #[derive(Clone)] pub struct InheritedCallWeightAttr { pub typename: syn::Type, - pub span: proc_macro2::Span, } impl syn::parse::Parse for InheritedCallWeightAttr { @@ -744,6 +742,6 @@ impl syn::parse::Parse for InheritedCallWeightAttr { return Err(lookahead.error()) }; - Ok(Self { typename: buffer.parse()?, span: input.span() }) + Ok(Self { typename: buffer.parse()? }) } } diff --git a/substrate/frame/support/procedural/src/pallet/parse/origin.rs b/substrate/frame/support/procedural/src/pallet/parse/origin.rs index 76e2a8841196..11311b3d5033 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/origin.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/origin.rs @@ -25,16 +25,13 @@ use syn::spanned::Spanned; /// * `struct Origin` /// * `enum Origin` pub struct OriginDef { - /// The index of item in pallet module. - pub index: usize, - pub has_instance: bool, pub is_generic: bool, /// A set of usage of instance, must be check for consistency with trait. pub instances: Vec, } impl OriginDef { - pub fn try_from(index: usize, item: &mut syn::Item) -> syn::Result { + pub fn try_from(item: &mut syn::Item) -> syn::Result { let item_span = item.span(); let (vis, ident, generics) = match &item { syn::Item::Enum(item) => (&item.vis, &item.ident, &item.generics), @@ -46,7 +43,6 @@ impl OriginDef { }, }; - let has_instance = generics.params.len() == 2; let is_generic = !generics.params.is_empty(); let mut instances = vec![]; @@ -67,6 +63,6 @@ impl OriginDef { return Err(syn::Error::new(ident.span(), msg)) } - Ok(OriginDef { index, has_instance, is_generic, instances }) + Ok(OriginDef { is_generic, instances }) } } diff --git a/substrate/frame/support/procedural/src/pallet/parse/tasks.rs b/substrate/frame/support/procedural/src/pallet/parse/tasks.rs index 6405bb415a6f..ed860849a4db 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/tasks.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/tasks.rs @@ -34,8 +34,8 @@ use syn::{ parse2, spanned::Spanned, token::{Bracket, Paren, PathSep, Pound}, - Attribute, Error, Expr, Ident, ImplItem, ImplItemFn, ItemEnum, ItemImpl, LitInt, Path, - PathArguments, Result, TypePath, + Error, Expr, Ident, ImplItem, ImplItemFn, ItemEnum, ItemImpl, LitInt, Path, PathArguments, + Result, TypePath, }; pub mod keywords { @@ -180,7 +180,6 @@ pub struct TaskDef { pub condition_attr: TaskConditionAttr, pub list_attr: TaskListAttr, pub weight_attr: TaskWeightAttr, - pub normal_attrs: Vec, pub item: ImplItemFn, pub arg_names: Vec, } @@ -190,7 +189,7 @@ impl syn::parse::Parse for TaskDef { let item = input.parse::()?; // we only want to activate TaskAttrType parsing errors for tasks-related attributes, // so we filter them here - let (task_attrs, normal_attrs) = partition_task_attrs(&item); + let task_attrs = partition_task_attrs(&item).0; let task_attrs: Vec = task_attrs .into_iter() @@ -293,15 +292,7 @@ impl syn::parse::Parse for TaskDef { let list_attr = list_attr.try_into().expect("we check the type above; QED"); let weight_attr = weight_attr.try_into().expect("we check the type above; QED"); - Ok(TaskDef { - index_attr, - condition_attr, - list_attr, - weight_attr, - normal_attrs, - item, - arg_names, - }) + Ok(TaskDef { index_attr, condition_attr, list_attr, weight_attr, item, arg_names }) } } diff --git a/substrate/frame/support/procedural/src/pallet/parse/type_value.rs b/substrate/frame/support/procedural/src/pallet/parse/type_value.rs index 4d9db30b3a78..b9c0635bb3f5 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/type_value.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/type_value.rs @@ -28,12 +28,8 @@ pub struct TypeValueDef { pub ident: syn::Ident, /// The type return by Get. pub type_: Box, - /// The block returning the value to get - pub block: Box, /// If type value is generic over `T` (or `T` and `I` for instantiable pallet) pub is_generic: bool, - /// A set of usage of instance, must be check for consistency with config. - pub instances: Vec, /// The where clause of the function. pub where_clause: Option, /// The span of the pallet::type_value attribute. @@ -90,7 +86,6 @@ impl TypeValueDef { let vis = item.vis.clone(); let ident = item.sig.ident.clone(); - let block = item.block.clone(); let type_ = match item.sig.output.clone() { syn::ReturnType::Type(_, type_) => type_, syn::ReturnType::Default => { @@ -99,25 +94,11 @@ impl TypeValueDef { }, }; - let mut instances = vec![]; - if let Some(usage) = helper::check_type_value_gen(&item.sig.generics, item.sig.span())? { - instances.push(usage); - } + helper::check_type_value_gen(&item.sig.generics, item.sig.span())?; let is_generic = item.sig.generics.type_params().count() > 0; let where_clause = item.sig.generics.where_clause.clone(); - Ok(TypeValueDef { - attr_span, - index, - is_generic, - vis, - ident, - block, - type_, - instances, - where_clause, - docs, - }) + Ok(TypeValueDef { attr_span, index, is_generic, vis, ident, type_, where_clause, docs }) } } diff --git a/substrate/frame/support/procedural/src/pallet/parse/validate_unsigned.rs b/substrate/frame/support/procedural/src/pallet/parse/validate_unsigned.rs index 2bf0a1b6c188..038db0d32581 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/validate_unsigned.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/validate_unsigned.rs @@ -19,15 +19,10 @@ use super::helper; use syn::spanned::Spanned; /// The definition of the pallet validate unsigned implementation. -pub struct ValidateUnsignedDef { - /// The index of validate unsigned item in pallet module. - pub index: usize, - /// A set of usage of instance, must be check for consistency with config. - pub instances: Vec, -} +pub struct ValidateUnsignedDef {} impl ValidateUnsignedDef { - pub fn try_from(index: usize, item: &mut syn::Item) -> syn::Result { + pub fn try_from(item: &mut syn::Item) -> syn::Result { let item = if let syn::Item::Impl(item) = item { item } else { @@ -52,11 +47,9 @@ impl ValidateUnsignedDef { return Err(syn::Error::new(item.span(), msg)) } - let instances = vec![ - helper::check_pallet_struct_usage(&item.self_ty)?, - helper::check_impl_gen(&item.generics, item.impl_token.span())?, - ]; + helper::check_pallet_struct_usage(&item.self_ty)?; + helper::check_impl_gen(&item.generics, item.impl_token.span())?; - Ok(ValidateUnsignedDef { index, instances }) + Ok(ValidateUnsignedDef {}) } } diff --git a/substrate/frame/support/procedural/src/runtime/parse/mod.rs b/substrate/frame/support/procedural/src/runtime/parse/mod.rs index 49647993aac7..a3d1c9417df8 100644 --- a/substrate/frame/support/procedural/src/runtime/parse/mod.rs +++ b/substrate/frame/support/procedural/src/runtime/parse/mod.rs @@ -109,7 +109,6 @@ pub enum AllPalletsDeclaration { /// Declaration of a runtime with some pallet with implicit declaration of parts. #[derive(Debug, Clone)] pub struct ImplicitAllPalletsDeclaration { - pub name: Ident, pub pallet_decls: Vec, pub pallet_count: usize, } @@ -123,7 +122,6 @@ pub struct ExplicitAllPalletsDeclaration { pub struct Def { pub input: TokenStream2, - pub item: syn::ItemMod, pub runtime_struct: runtime_struct::RuntimeStructDef, pub pallets: AllPalletsDeclaration, pub runtime_types: Vec, @@ -161,8 +159,8 @@ impl Def { helper::take_first_item_runtime_attr::(item)? { match runtime_attr { - RuntimeAttr::Runtime(span) if runtime_struct.is_none() => { - let p = runtime_struct::RuntimeStructDef::try_from(span, item)?; + RuntimeAttr::Runtime(_) if runtime_struct.is_none() => { + let p = runtime_struct::RuntimeStructDef::try_from(item)?; runtime_struct = Some(p); }, RuntimeAttr::Derive(_, types) if runtime_types.is_none() => { @@ -240,7 +238,6 @@ impl Def { let decl_count = pallet_decls.len(); let pallets = if decl_count > 0 { AllPalletsDeclaration::Implicit(ImplicitAllPalletsDeclaration { - name, pallet_decls, pallet_count: decl_count.saturating_add(pallets.len()), }) @@ -250,7 +247,6 @@ impl Def { let def = Def { input, - item, runtime_struct: runtime_struct.ok_or_else(|| { syn::Error::new(item_span, "Missing Runtime. Please add a struct inside the module and annotate it with `#[runtime::runtime]`" diff --git a/substrate/frame/support/procedural/src/runtime/parse/pallet_decl.rs b/substrate/frame/support/procedural/src/runtime/parse/pallet_decl.rs index fbac75336f25..d34df77b7cfc 100644 --- a/substrate/frame/support/procedural/src/runtime/parse/pallet_decl.rs +++ b/substrate/frame/support/procedural/src/runtime/parse/pallet_decl.rs @@ -15,15 +15,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -use syn::{Attribute, Ident, PathArguments}; +use syn::{Ident, PathArguments}; /// The declaration of a pallet. #[derive(Debug, Clone)] pub struct PalletDeclaration { /// The name of the pallet, e.g.`System` in `pub type System = frame_system`. pub name: Ident, - /// Optional attributes tagged right above a pallet declaration. - pub attrs: Vec, /// The path of the pallet, e.g. `frame_system` in `pub type System = frame_system`. pub path: syn::Path, /// The segment of the pallet, e.g. `Pallet` in `pub type System = frame_system::Pallet`. @@ -91,7 +89,7 @@ impl PalletDeclaration { }; } - Ok(Self { name, path, pallet_segment, runtime_param, instance, attrs: item.attrs.clone() }) + Ok(Self { name, path, pallet_segment, runtime_param, instance }) } } diff --git a/substrate/frame/support/procedural/src/runtime/parse/runtime_struct.rs b/substrate/frame/support/procedural/src/runtime/parse/runtime_struct.rs index 8fa746ee8072..33c845ee946b 100644 --- a/substrate/frame/support/procedural/src/runtime/parse/runtime_struct.rs +++ b/substrate/frame/support/procedural/src/runtime/parse/runtime_struct.rs @@ -18,11 +18,10 @@ use syn::spanned::Spanned; pub struct RuntimeStructDef { pub ident: syn::Ident, - pub attr_span: proc_macro2::Span, } impl RuntimeStructDef { - pub fn try_from(attr_span: proc_macro2::Span, item: &mut syn::Item) -> syn::Result { + pub fn try_from(item: &mut syn::Item) -> syn::Result { let item = if let syn::Item::Struct(item) = item { item } else { @@ -30,6 +29,6 @@ impl RuntimeStructDef { return Err(syn::Error::new(item.span(), msg)) }; - Ok(Self { ident: item.ident.clone(), attr_span }) + Ok(Self { ident: item.ident.clone() }) } }