Skip to content

Commit

Permalink
upgrade to macro_magic 0.4.3 (paritytech#1832)
Browse files Browse the repository at this point in the history
# Description

Upgrades `macro_magic` to 0.4.3, which introduces the ability to have
`export_tokens` use the same name as the underlying item for its
auto-generated macro name. Ultimately this will allow for better dev ux
in our derive_impl feature.
  • Loading branch information
sam0x17 authored Oct 10, 2023
1 parent 5936d37 commit 6355416
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion substrate/frame/support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sp-weights = { path = "../../primitives/weights", default-features = false}
sp-debug-derive = { path = "../../primitives/debug-derive", default-features = false}
sp-metadata-ir = { path = "../../primitives/metadata-ir", default-features = false}
tt-call = "1.0.8"
macro_magic = "0.4.2"
macro_magic = "0.5.0"
frame-support-procedural = { path = "procedural", default-features = false}
paste = "1.0"
sp-state-machine = { path = "../../primitives/state-machine", default-features = false, optional = true}
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/support/procedural/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ proc-macro2 = "1.0.56"
quote = "1.0.28"
syn = { version = "2.0.38", features = ["full"] }
frame-support-procedural-tools = { path = "tools" }
macro_magic = { version = "0.5.0", features = ["proc_support"] }
proc-macro-warning = { version = "1.0.0", default-features = false }
macro_magic = { version = "0.4.2", features = ["proc_support"] }
expander = "2.0.0"
sp-core-hashing = { path = "../../../primitives/core/hashing" }

Expand Down
9 changes: 7 additions & 2 deletions substrate/frame/support/procedural/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,12 @@ pub fn register_default_impl(attrs: TokenStream, tokens: TokenStream) -> TokenSt
let item_impl = syn::parse_macro_input!(tokens as ItemImpl);

// internally wrap macro_magic's `#[export_tokens]` macro
match macro_magic::mm_core::export_tokens_internal(attrs, item_impl.to_token_stream(), true) {
match macro_magic::mm_core::export_tokens_internal(
attrs,
item_impl.to_token_stream(),
true,
true,
) {
Ok(tokens) => tokens.into(),
Err(err) => err.to_compile_error().into(),
}
Expand Down Expand Up @@ -1565,7 +1570,7 @@ pub fn pallet_section(attr: TokenStream, tokens: TokenStream) -> TokenStream {
let _mod = parse_macro_input!(tokens_clone as ItemMod);

// use macro_magic's export_tokens as the internal implementation otherwise
match macro_magic::mm_core::export_tokens_internal(attr, tokens, false) {
match macro_magic::mm_core::export_tokens_internal(attr, tokens, false, true) {
Ok(tokens) => tokens.into(),
Err(err) => err.to_compile_error().into(),
}
Expand Down

0 comments on commit 6355416

Please sign in to comment.