chore: regenerate umbrella crate, fix feature propagation

This commit is contained in:
2025-12-16 11:28:32 +03:00
parent dd6d48f528
commit 620b0e3aa0
1358 changed files with 9464 additions and 7656 deletions
@@ -191,8 +191,9 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
.collect::<Vec<_>>()
});
let default_docs =
[syn::parse_quote!(r"Contains a variant per dispatchable extrinsic that this pezpallet has.")];
let default_docs = [syn::parse_quote!(
r"Contains a variant per dispatchable extrinsic that this pezpallet has."
)];
let docs = if docs.is_empty() { &default_docs[..] } else { &docs[..] };
let maybe_compile_error = if def.call.is_none() {
@@ -35,12 +35,13 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
let type_decl_gen = &def.type_decl_generics(def.pezpallet_struct.attr_span);
let pezpallet_ident = &def.pezpallet_struct.pezpallet;
let config_where_clause = &def.config.where_clause;
let deprecation_status =
match crate::deprecation::get_deprecation(&quote::quote! {#pezframe_support}, &def.item.attrs)
{
Ok(deprecation) => deprecation,
Err(e) => return e.into_compile_error(),
};
let deprecation_status = match crate::deprecation::get_deprecation(
&quote::quote! {#pezframe_support},
&def.item.attrs,
) {
Ok(deprecation) => deprecation,
Err(e) => return e.into_compile_error(),
};
let mut storages_where_clauses = vec![&def.config.where_clause];
storages_where_clauses.extend(def.storages.iter().map(|storage| &storage.where_clause));
@@ -105,8 +106,10 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream {
)
};
let storage_info_span =
def.pezpallet_struct.without_storage_info.unwrap_or(def.pezpallet_struct.attr_span);
let storage_info_span = def
.pezpallet_struct
.without_storage_info
.unwrap_or(def.pezpallet_struct.attr_span);
let storage_names = &def.storages.iter().map(|storage| &storage.ident).collect::<Vec<_>>();
let storage_cfg_attrs =
@@ -157,7 +157,8 @@ pub fn process_generics(def: &mut Def) -> syn::Result<Vec<ResultOnEmptyStructMet
}
syn::parse_quote!(#pezframe_support::traits::GetDefault)
};
let default_max_values: syn::Type = syn::parse_quote!(#pezframe_support::traits::GetDefault);
let default_max_values: syn::Type =
syn::parse_quote!(#pezframe_support::traits::GetDefault);
let set_result_query_type_parameter = |query_type: &mut syn::Type| -> syn::Result<()> {
if let Some(QueryKind::ResultQuery(error_path, _)) = storage_def.query_kind.as_ref() {
@@ -860,8 +861,8 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream {
.iter()
.filter_map(|storage| {
// A little hacky; don't generate for cfg gated storages to not get compile errors
// when building "frame-feature-testing" gated storages in the "pezframe-support-test"
// crate.
// when building "frame-feature-testing" gated storages in the
// "pezframe-support-test" crate.
if storage.try_decode && storage.cfg_attrs.is_empty() {
let ident = &storage.ident;
let gen = &def.type_use_generics(storage.attr_span);
@@ -298,7 +298,8 @@ impl CallDef {
return Err(syn::Error::new(method.sig.span(), msg));
},
Some(syn::FnArg::Receiver(_)) => {
let msg = "Invalid pezpallet::call, first argument must be a typed argument, \
let msg =
"Invalid pezpallet::call, first argument must be a typed argument, \
e.g. `origin: OriginFor<T>`";
return Err(syn::Error::new(method.sig.span(), msg));
},
@@ -329,7 +330,8 @@ impl CallDef {
},
FunctionAttr::Weight(w) => {
if weight.is_some() {
let msg = "Invalid pezpallet::call, too many weight attributes given";
let msg =
"Invalid pezpallet::call, too many weight attributes given";
return Err(syn::Error::new(method.sig.span(), msg));
}
weight = Some(w);
@@ -91,7 +91,8 @@ pub struct CompositeDef {
pub composite_keyword: keyword::CompositeKeyword,
/// Name of the associated type.
pub ident: syn::Ident,
/// Type parameters and where clause attached to a declaration of the pezpallet::composite_enum.
/// Type parameters and where clause attached to a declaration of the
/// pezpallet::composite_enum.
pub generics: syn::Generics,
/// The span of the pezpallet::composite_enum attribute.
pub attr_span: proc_macro2::Span,
@@ -16,7 +16,9 @@
// limitations under the License.
use super::helper;
use pezframe_support_procedural_tools::{get_cfg_attributes, get_doc_literals, is_using_frame_crate};
use pezframe_support_procedural_tools::{
get_cfg_attributes, get_doc_literals, is_using_frame_crate,
};
use proc_macro_warning::Warning;
use quote::ToTokens;
use syn::{parse_quote, spanned::Spanned, token, Token, TraitItemType};
@@ -43,8 +45,8 @@ mod keyword {
#[derive(Default)]
pub struct DefaultTrait {
/// A bool for each sub-trait item indicates whether the item has
/// `#[pezpallet::no_default_bounds]` attached to it. If true, the item will not have any bounds
/// in the generated default sub-trait.
/// `#[pezpallet::no_default_bounds]` attached to it. If true, the item will not have any
/// bounds in the generated default sub-trait.
pub items: Vec<(syn::TraitItem, bool)>,
pub has_system: bool,
}
@@ -305,15 +307,17 @@ fn has_expected_system_config(path: syn::Path, pezframe_system: &syn::Path) -> b
let mut expected_system_config =
match (is_using_frame_crate(&path), is_using_frame_crate(&pezframe_system)) {
(true, false) =>
// We can't use the path to `pezframe_system` from `frame` if `pezframe_system` is not being
// in scope through `frame`.
// We can't use the path to `pezframe_system` from `frame` if `pezframe_system` is not
// being in scope through `frame`.
return false,
(false, true) =>
// We know that the only valid pezframe_system path is one that is `pezframe_system`, as
// `frame` re-exports it as such.
syn::parse2::<syn::Path>(quote::quote!(pezframe_system)).expect("is a valid path; qed"),
syn::parse2::<syn::Path>(quote::quote!(pezframe_system))
.expect("is a valid path; qed"),
(_, _) =>
// They are either both `pezframe_system` or both `pezkuwi_sdk_frame::xyz::pezframe_system`.
// They are either both `pezframe_system` or both
// `pezkuwi_sdk_frame::xyz::pezframe_system`.
pezframe_system.clone(),
};
@@ -634,7 +638,8 @@ mod tests {
let path = syn::parse2::<syn::Path>(quote::quote!(pezframe_system::Config)).unwrap();
let pezframe_system =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::deps::pezframe_system)).unwrap();
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::deps::pezframe_system))
.unwrap();
assert!(has_expected_system_config(path.clone(), &pezframe_system));
let pezframe_system =
@@ -645,10 +650,12 @@ mod tests {
#[test]
fn has_expected_system_config_works_with_frame_full_path() {
let pezframe_system =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::deps::pezframe_system)).unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::deps::pezframe_system::Config))
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::deps::pezframe_system))
.unwrap();
let path = syn::parse2::<syn::Path>(quote::quote!(
pezkuwi_sdk_frame::deps::pezframe_system::Config
))
.unwrap();
assert!(has_expected_system_config(path, &pezframe_system));
let pezframe_system =
@@ -661,10 +668,12 @@ mod tests {
#[test]
fn has_expected_system_config_works_with_other_frame_full_path() {
let pezframe_system =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::xyz::pezframe_system)).unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::xyz::pezframe_system::Config))
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::xyz::pezframe_system))
.unwrap();
let path = syn::parse2::<syn::Path>(quote::quote!(
pezkuwi_sdk_frame::xyz::pezframe_system::Config
))
.unwrap();
assert!(has_expected_system_config(path, &pezframe_system));
let pezframe_system =
@@ -677,29 +686,34 @@ mod tests {
#[test]
fn has_expected_system_config_does_not_works_with_mixed_frame_full_path() {
let pezframe_system =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::xyz::pezframe_system)).unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::deps::pezframe_system::Config))
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::xyz::pezframe_system))
.unwrap();
let path = syn::parse2::<syn::Path>(quote::quote!(
pezkuwi_sdk_frame::deps::pezframe_system::Config
))
.unwrap();
assert!(!has_expected_system_config(path, &pezframe_system));
}
#[test]
fn has_expected_system_config_does_not_works_with_other_mixed_frame_full_path() {
let pezframe_system =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::deps::pezframe_system)).unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::xyz::pezframe_system::Config))
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::deps::pezframe_system))
.unwrap();
let path = syn::parse2::<syn::Path>(quote::quote!(
pezkuwi_sdk_frame::xyz::pezframe_system::Config
))
.unwrap();
assert!(!has_expected_system_config(path, &pezframe_system));
}
#[test]
fn has_expected_system_config_does_not_work_with_frame_full_path_if_not_frame_crate() {
let pezframe_system = syn::parse2::<syn::Path>(quote::quote!(pezframe_system)).unwrap();
let path =
syn::parse2::<syn::Path>(quote::quote!(pezkuwi_sdk_frame::deps::pezframe_system::Config))
.unwrap();
let path = syn::parse2::<syn::Path>(quote::quote!(
pezkuwi_sdk_frame::deps::pezframe_system::Config
))
.unwrap();
assert!(!has_expected_system_config(path, &pezframe_system));
}
@@ -67,7 +67,10 @@ impl ErrorDef {
let item = if let syn::Item::Enum(item) = item {
item
} else {
return Err(syn::Error::new(item.span(), "Invalid pezpallet::error, expected item enum"));
return Err(syn::Error::new(
item.span(),
"Invalid pezpallet::error, expected item enum",
));
};
if !matches!(item.vis, syn::Visibility::Public(_)) {
let msg = "Invalid pezpallet::error, `Error` must be public";
@@ -80,41 +83,42 @@ impl ErrorDef {
vec![helper::check_type_def_gen_no_bounds(&item.generics, item.ident.span())?];
if item.generics.where_clause.is_some() {
let msg = "Invalid pezpallet::error, where clause is not allowed on pezpallet error item";
let msg =
"Invalid pezpallet::error, where clause is not allowed on pezpallet error item";
return Err(syn::Error::new(item.generics.where_clause.as_ref().unwrap().span(), msg));
}
let error = syn::parse2::<keyword::Error>(item.ident.to_token_stream())?;
let variants = item
.variants
.iter()
.map(|variant| {
let field_ty = match &variant.fields {
Fields::Unit => None,
Fields::Named(_) => Some(VariantField { is_named: true }),
Fields::Unnamed(_) => Some(VariantField { is_named: false }),
};
let variants =
item.variants
.iter()
.map(|variant| {
let field_ty = match &variant.fields {
Fields::Unit => None,
Fields::Named(_) => Some(VariantField { is_named: true }),
Fields::Unnamed(_) => Some(VariantField { is_named: false }),
};
match &variant.discriminant {
None |
Some((_, syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Int(_), .. }))) => {},
Some((_, expr)) => {
let msg = "Invalid pezpallet::error, only integer discriminants are supported";
return Err(syn::Error::new(expr.span(), msg));
},
}
let cfg_attrs: Vec<syn::Attribute> = helper::get_item_cfg_attrs(&variant.attrs);
let maybe_allow_attrs = extract_or_return_allow_attrs(&variant.attrs).collect();
match &variant.discriminant {
None |
Some((_, syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Int(_), .. }))) => {},
Some((_, expr)) => {
let msg = "Invalid pezpallet::error, only integer discriminants are supported";
return Err(syn::Error::new(expr.span(), msg));
},
}
let cfg_attrs: Vec<syn::Attribute> = helper::get_item_cfg_attrs(&variant.attrs);
let maybe_allow_attrs = extract_or_return_allow_attrs(&variant.attrs).collect();
Ok(VariantDef {
ident: variant.ident.clone(),
field: field_ty,
cfg_attrs,
maybe_allow_attrs,
Ok(VariantDef {
ident: variant.ident.clone(),
field: field_ty,
cfg_attrs,
maybe_allow_attrs,
})
})
})
.collect::<Result<_, _>>()?;
.collect::<Result<_, _>>()?;
Ok(ErrorDef { attr_span, index, variants, instances, error })
}
@@ -104,7 +104,10 @@ impl EventDef {
let item = if let syn::Item::Enum(item) = item {
item
} else {
return Err(syn::Error::new(item.span(), "Invalid pezpallet::event, expected enum item"));
return Err(syn::Error::new(
item.span(),
"Invalid pezpallet::event, expected enum item",
));
};
crate::deprecation::prevent_deprecation_attr_on_outer_enum(&item.attrs)?;
@@ -48,7 +48,8 @@ pub trait MutItemAttrs {
fn mut_item_attrs(&mut self) -> Option<&mut Vec<syn::Attribute>>;
}
/// Take the first pezpallet attribute (e.g. attribute like `#[pezpallet..]`) and decode it to `Attr`
/// Take the first pezpallet attribute (e.g. attribute like `#[pezpallet..]`) and decode it to
/// `Attr`
pub(crate) fn take_first_item_pallet_attr<Attr>(
item: &mut impl MutItemAttrs,
) -> syn::Result<Option<Attr>>
@@ -58,7 +59,10 @@ where
let Some(attrs) = item.mut_item_attrs() else { return Ok(None) };
let Some(index) = attrs.iter().position(|attr| {
attr.path().segments.first().map_or(false, |segment| segment.ident == "pezpallet")
attr.path()
.segments
.first()
.map_or(false, |segment| segment.ident == "pezpallet")
}) else {
return Ok(None);
};
@@ -67,7 +71,8 @@ where
Ok(Some(syn::parse2(pezpallet_attr.into_token_stream())?))
}
/// Take all the pezpallet attributes (e.g. attribute like `#[pezpallet..]`) and decode them to `Attr`
/// Take all the pezpallet attributes (e.g. attribute like `#[pezpallet..]`) and decode them to
/// `Attr`
pub(crate) fn take_item_pallet_attrs<Attr>(item: &mut impl MutItemAttrs) -> syn::Result<Vec<Attr>>
where
Attr: syn::parse::Parse,
@@ -34,7 +34,8 @@ impl InherentDef {
};
if item.trait_.is_none() {
let msg = "Invalid pezpallet::inherent, expected impl<..> ProvideInherent for Pezpallet<..>";
let msg =
"Invalid pezpallet::inherent, expected impl<..> ProvideInherent for Pezpallet<..>";
return Err(syn::Error::new(item.span(), msg));
}
@@ -44,7 +45,8 @@ impl InherentDef {
return Err(syn::Error::new(last.span(), msg));
}
} else {
let msg = "Invalid pezpallet::inherent, expected impl<..> ProvideInherent for Pezpallet<..>";
let msg =
"Invalid pezpallet::inherent, expected impl<..> ProvideInherent for Pezpallet<..>";
return Err(syn::Error::new(item.span(), msg));
}
@@ -609,8 +609,9 @@ enum PalletAttr {
/// Can be used to reduce the repetitive weight annotation in the trivial case. It accepts one
/// argument that is expected to be an implementation of the `WeightInfo` or something that
/// behaves syntactically equivalent. This allows to annotate a `WeightInfo` for all the calls.
/// Now each call does not need to specify its own `#[pezpallet::weight]` but can instead use the
/// one from the `#[pezpallet::call]` definition. So instead of having to write it on each call:
/// Now each call does not need to specify its own `#[pezpallet::weight]` but can instead use
/// the one from the `#[pezpallet::call]` definition. So instead of having to write it on each
/// call:
///
/// ```ignore
/// #[pezpallet::call]
@@ -631,9 +632,10 @@ enum PalletAttr {
///
/// ### Dev Mode
///
/// Normally the `dev_mode` sets all weights of calls without a `#[pezpallet::weight]` annotation
/// to zero. Now when there is a `weight` attribute on the `#[pezpallet::call]`, then that is used
/// instead of the zero weight. So to say: it works together with `dev_mode`.
/// Normally the `dev_mode` sets all weights of calls without a `#[pezpallet::weight]`
/// annotation to zero. Now when there is a `weight` attribute on the `#[pezpallet::call]`,
/// then that is used instead of the zero weight. So to say: it works together with
/// `dev_mode`.
RuntimeCall(Option<InheritedCallWeightAttr>, proc_macro2::Span),
Error(proc_macro2::Span),
Tasks(proc_macro2::Span),
@@ -803,7 +805,8 @@ impl syn::parse::Parse for PalletAttr {
}
}
/// The optional weight annotation on a `#[pezpallet::call]` like `#[pezpallet::call(weight($type))]`.
/// The optional weight annotation on a `#[pezpallet::call]` like
/// `#[pezpallet::call(weight($type))]`.
#[derive(Clone)]
pub struct InheritedCallWeightAttr {
pub typename: syn::Type,
@@ -130,7 +130,8 @@ impl PalletStructDef {
}
if item.generics.where_clause.is_some() {
let msg = "Invalid pezpallet::pezpallet, where clause not supported on Pezpallet declaration";
let msg =
"Invalid pezpallet::pezpallet, where clause not supported on Pezpallet declaration";
return Err(syn::Error::new(item.generics.where_clause.span(), msg));
}
@@ -704,7 +704,8 @@ fn process_generics(
.collect::<Vec<_>>();
process_named_generics(&storage_kind, args_span, &args, dev_mode)
} else {
let msg = "Invalid pezpallet::storage, invalid generic declaration for storage. Expect only \
let msg =
"Invalid pezpallet::storage, invalid generic declaration for storage. Expect only \
type generics or binding generics, e.g. `<Name1 = Gen1, Name2 = Gen2, ..>` or \
`<Gen1, Gen2, ..>`.";
Err(syn::Error::new(segment.span(), msg))
@@ -792,7 +793,10 @@ impl StorageDef {
let item = if let syn::Item::Type(item) = item {
item
} else {
return Err(syn::Error::new(item.span(), "Invalid pezpallet::storage, expect item type."));
return Err(syn::Error::new(
item.span(),
"Invalid pezpallet::storage, expect item type.",
));
};
let attrs: Vec<PalletStorageAttr> = helper::take_item_pallet_attrs(&mut item.attrs)?;
@@ -920,7 +924,8 @@ impl StorageDef {
.unwrap_or(Some(QueryKind::OptionQuery));
if let (None, Some(getter)) = (query_kind.as_ref(), getter.as_ref()) {
let msg = "Invalid pezpallet::storage, cannot generate getter because QueryKind is not \
let msg =
"Invalid pezpallet::storage, cannot generate getter because QueryKind is not \
identifiable. QueryKind must be `OptionQuery`, `ResultQuery`, `ValueQuery`, or default \
one to be identifiable.";
return Err(syn::Error::new(getter.span(), msg));
@@ -506,7 +506,10 @@ fn extract_pallet_attr(item_enum: &mut ItemEnum) -> Result<Option<TokenStream2>>
.cloned()
.collect();
if let Some(span) = duplicate {
return Err(Error::new(span, "only one `#[pezpallet::_]` attribute is supported on this item"));
return Err(Error::new(
span,
"only one `#[pezpallet::_]` attribute is supported on this item",
));
}
Ok(attr)
}
@@ -60,7 +60,8 @@ impl TypeValueDef {
}
}
let msg = "Invalid pezpallet::type_value, unexpected attribute, only doc attribute are \
let msg =
"Invalid pezpallet::type_value, unexpected attribute, only doc attribute are \
allowed";
return Err(syn::Error::new(attr.span(), msg));
}
@@ -31,7 +31,8 @@ impl ValidateUnsignedDef {
};
if item.trait_.is_none() {
let msg = "Invalid pezpallet::validate_unsigned, expected impl<..> ValidateUnsigned for \
let msg =
"Invalid pezpallet::validate_unsigned, expected impl<..> ValidateUnsigned for \
Pezpallet<..>";
return Err(syn::Error::new(item.span(), msg));
}
@@ -42,7 +43,8 @@ impl ValidateUnsignedDef {
return Err(syn::Error::new(last.span(), msg));
}
} else {
let msg = "Invalid pezpallet::validate_unsigned, expected impl<..> ValidateUnsigned for \
let msg =
"Invalid pezpallet::validate_unsigned, expected impl<..> ValidateUnsigned for \
Pezpallet<..>";
return Err(syn::Error::new(item.span(), msg));
}
@@ -15,8 +15,8 @@
// See the License for the specific language governsing permissions and
// limitations under the License.
use pezframe_support_procedural_tools::get_doc_literals;
use inflector::Inflector;
use pezframe_support_procedural_tools::get_doc_literals;
use syn::spanned::Spanned;
/// Parsed representation of an impl block annotated with `pezpallet::view_functions`.