mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-08 13:37:22 +00:00
Fixes parsing for config attrs in pallet macros (#2677)
This commit is contained in:
@@ -85,6 +85,8 @@ pub struct CallVariantDef {
|
||||
pub docs: Vec<syn::Expr>,
|
||||
/// Attributes annotated at the top of the dispatchable function.
|
||||
pub attrs: Vec<syn::Attribute>,
|
||||
/// The `cfg` attributes.
|
||||
pub cfg_attrs: Vec<syn::Attribute>,
|
||||
/// The optional `feeless_if` attribute on the `pallet::call`.
|
||||
pub feeless_check: Option<syn::ExprClosure>,
|
||||
}
|
||||
@@ -266,6 +268,7 @@ impl CallDef {
|
||||
return Err(syn::Error::new(method.sig.span(), msg))
|
||||
}
|
||||
|
||||
let cfg_attrs: Vec<syn::Attribute> = helper::get_item_cfg_attrs(&method.attrs);
|
||||
let mut call_idx_attrs = vec![];
|
||||
let mut weight_attrs = vec![];
|
||||
let mut feeless_attrs = vec![];
|
||||
@@ -442,6 +445,7 @@ impl CallDef {
|
||||
args,
|
||||
docs,
|
||||
attrs: method.attrs.clone(),
|
||||
cfg_attrs,
|
||||
feeless_check,
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -25,19 +25,31 @@ mod keyword {
|
||||
syn::custom_keyword!(Error);
|
||||
}
|
||||
|
||||
/// Records information about the error enum variants.
|
||||
/// Records information about the error enum variant field.
|
||||
pub struct VariantField {
|
||||
/// Whether or not the field is named, i.e. whether it is a tuple variant or struct variant.
|
||||
pub is_named: bool,
|
||||
}
|
||||
|
||||
/// Records information about the error enum variants.
|
||||
pub struct VariantDef {
|
||||
/// The variant ident.
|
||||
pub ident: syn::Ident,
|
||||
/// The variant field, if any.
|
||||
pub field: Option<VariantField>,
|
||||
/// The variant doc literals.
|
||||
pub docs: Vec<syn::Expr>,
|
||||
/// The `cfg` attributes.
|
||||
pub cfg_attrs: Vec<syn::Attribute>,
|
||||
}
|
||||
|
||||
/// This checks error declaration as a enum declaration with only variants without fields nor
|
||||
/// discriminant.
|
||||
pub struct ErrorDef {
|
||||
/// The index of error item in pallet module.
|
||||
pub index: usize,
|
||||
/// Variants ident, optional field and doc literals (ordered as declaration order)
|
||||
pub variants: Vec<(syn::Ident, Option<VariantField>, Vec<syn::Expr>)>,
|
||||
/// Variant definitions.
|
||||
pub variants: Vec<VariantDef>,
|
||||
/// A set of usage of instance, must be check for consistency with trait.
|
||||
pub instances: Vec<helper::InstanceUsage>,
|
||||
/// The keyword error used (contains span).
|
||||
@@ -87,8 +99,14 @@ impl ErrorDef {
|
||||
let span = variant.discriminant.as_ref().unwrap().0.span();
|
||||
return Err(syn::Error::new(span, msg))
|
||||
}
|
||||
let cfg_attrs: Vec<syn::Attribute> = helper::get_item_cfg_attrs(&variant.attrs);
|
||||
|
||||
Ok((variant.ident.clone(), field_ty, get_doc_literals(&variant.attrs)))
|
||||
Ok(VariantDef {
|
||||
ident: variant.ident.clone(),
|
||||
field: field_ty,
|
||||
docs: get_doc_literals(&variant.attrs),
|
||||
cfg_attrs,
|
||||
})
|
||||
})
|
||||
.collect::<Result<_, _>>()?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user