Fixes path issue in derive-impl (#1823)

Needs https://github.com/sam0x17/macro_magic/pull/13

The associated PR allows the export of tokens from macro_magic at the
specified path. This fixes the path issue in derive-impl. Now, we can
import the default config using the standard rust syntax:

```rust
use frame_system::config_preludes::TestDefaultConfig;

[derive_impl(TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::DefaultConfig for Test {
   //....
}
```
This commit is contained in:
gupnik
2023-10-11 07:26:13 +02:00
committed by GitHub
parent 5adcb3e106
commit 294e99831d
4 changed files with 11 additions and 12 deletions
@@ -34,7 +34,7 @@ mod transactional;
mod tt_macro;
use frame_support_procedural_tools::generate_crate_access_2018;
use macro_magic::import_tokens_attr;
use macro_magic::{import_tokens_attr, import_tokens_attr_verbatim};
use proc_macro::TokenStream;
use quote::{quote, ToTokens};
use std::{cell::RefCell, str::FromStr};
@@ -751,7 +751,7 @@ pub fn storage_alias(attributes: TokenStream, input: TokenStream) -> TokenStream
/// Items that lack a `syn::Ident` for whatever reason are first checked to see if they exist,
/// verbatim, in the local/destination trait before they are copied over, so you should not need to
/// worry about collisions between identical unnamed items.
#[import_tokens_attr {
#[import_tokens_attr_verbatim {
format!(
"{}::macro_magic",
match generate_crate_access_2018("frame-support") {
@@ -868,7 +868,7 @@ pub fn register_default_impl(attrs: TokenStream, tokens: TokenStream) -> TokenSt
attrs,
item_impl.to_token_stream(),
true,
true,
false,
) {
Ok(tokens) => tokens.into(),
Err(err) => err.to_compile_error().into(),