Improve spans of pallet macro (#7830)

* fix spans

* convert name to snake case
This commit is contained in:
Guillaume Thiolliere
2021-01-06 10:16:05 +01:00
committed by GitHub
parent d2ac8bd941
commit 66a9093fa3
27 changed files with 303 additions and 144 deletions
@@ -26,10 +26,16 @@ pub struct HooksDef {
pub instances: Vec<helper::InstanceUsage>,
/// The where_clause used.
pub where_clause: Option<syn::WhereClause>,
/// The span of the pallet::hooks attribute.
pub attr_span: proc_macro2::Span,
}
impl HooksDef {
pub fn try_from(index: usize, item: &mut syn::Item) -> syn::Result<Self> {
pub fn try_from(
attr_span: proc_macro2::Span,
index: usize,
item: &mut syn::Item,
) -> syn::Result<Self> {
let item = if let syn::Item::Impl(item) = item {
item
} else {
@@ -61,6 +67,7 @@ impl HooksDef {
}
Ok(Self {
attr_span,
index,
instances,
where_clause: item.generics.where_clause.clone(),