mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
update macro_magic to 0.4.1 (#14356)
* update to macro_magic 0.4.0 * remove deprecated syntax and related doc comments * upgrade to macro_magic v0.4.1 * fix import issue * fix UI tests * resolve frame_support path properly * add docs note about importing * fix typo * Update frame/support/procedural/src/lib.rs Co-authored-by: Guillaume Yu Thiolliere <gui.thiolliere@gmail.com> * revert UI tests changes because we can't use rust 1.70 * fix UI tests * fix another UI test * use simplified import style * switch back import since tests are written expecting it that way --------- Co-authored-by: Guillaume Yu Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
Generated
+8
-8
@@ -4845,9 +4845,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "macro_magic"
|
||||
version = "0.3.5"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0a2d6d7fe4741b5621cf7c8048e472933877c7ea870cbf1420da55ea9f3bb08c"
|
||||
checksum = "614b1304ab7877b499925b4dcc5223ff480f2646ad4db1ee7065badb8d530439"
|
||||
dependencies = [
|
||||
"macro_magic_core",
|
||||
"macro_magic_macros",
|
||||
@@ -4857,9 +4857,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "macro_magic_core"
|
||||
version = "0.3.5"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3005604258419767cacc5989c2dd75263f8b33773dd680734f598eb88baf5370"
|
||||
checksum = "a8d72c1b662d07b8e482c80d3a7fc4168e058b3bef4c573e94feb714b670f406"
|
||||
dependencies = [
|
||||
"derive-syn-parse",
|
||||
"macro_magic_core_macros",
|
||||
@@ -4870,9 +4870,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "macro_magic_core_macros"
|
||||
version = "0.3.5"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de6267819c9042df1a9e62ca279e5a34254ad5dfdcb13ff988f560d75576e8b4"
|
||||
checksum = "93d7d9e6e234c040dafc745c7592738d56a03ad04b1fa04ab60821deb597466a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -4881,9 +4881,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "macro_magic_macros"
|
||||
version = "0.3.5"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc7176ac15ab2ed7f335e2398f729b9562dae0c233705bc1e1e3acd8452d403d"
|
||||
checksum = "ffd19f13cfd2bfbd83692adfef8c244fe5109b3eb822a1fb4e0a6253b406cd81"
|
||||
dependencies = [
|
||||
"macro_magic_core",
|
||||
"quote",
|
||||
|
||||
@@ -106,12 +106,6 @@ pub mod pallet {
|
||||
#[cfg(any(test, doc))]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
use frame_support::macro_magic::use_attr;
|
||||
// Because `derive_impl` is a [macro_magic](https://crates.io/crates/macro_magic) attribute
|
||||
// macro, [`#[use_attr]`](`frame_support::macro_magic::use_attr`) must be attached to any use
|
||||
// statement that brings it into scope.
|
||||
#[use_attr]
|
||||
use frame_support::derive_impl;
|
||||
|
||||
use super::pallet as pallet_default_config_example;
|
||||
@@ -168,7 +162,7 @@ pub mod tests {
|
||||
}
|
||||
|
||||
// Similarly, we use the defaults provided by own crate as well.
|
||||
use pallet::config_preludes::TestDefaultConfig;
|
||||
use pallet::config_preludes::*;
|
||||
#[derive_impl(TestDefaultConfig as pallet::DefaultConfig)]
|
||||
impl crate::pallet::Config for Test {
|
||||
// These two both cannot have defaults.
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
//! Tests for pallet-example-kitchensink.
|
||||
|
||||
use crate::*;
|
||||
#[use_attr]
|
||||
use frame_support::derive_impl;
|
||||
use frame_support::{macro_magic::use_attr, parameter_types, traits::ConstU64};
|
||||
use frame_support::{derive_impl, parameter_types, traits::ConstU64};
|
||||
use sp_runtime::BuildStorage;
|
||||
// Reexport crate as its pallet name for construct_runtime.
|
||||
use crate as pallet_example_kitchensink;
|
||||
|
||||
@@ -29,7 +29,7 @@ sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../pr
|
||||
sp-weights = { version = "20.0.0", default-features = false, path = "../../primitives/weights" }
|
||||
sp-debug-derive = { default-features = false, path = "../../primitives/debug-derive" }
|
||||
tt-call = "1.0.8"
|
||||
macro_magic = "0.3.5"
|
||||
macro_magic = "0.4.1"
|
||||
frame-support-procedural = { version = "4.0.0-dev", default-features = false, path = "./procedural" }
|
||||
paste = "1.0"
|
||||
once_cell = { version = "1", default-features = false, optional = true }
|
||||
|
||||
@@ -24,7 +24,7 @@ quote = "1.0.28"
|
||||
syn = { version = "2.0.16", features = ["full"] }
|
||||
frame-support-procedural-tools = { version = "4.0.0-dev", path = "./tools" }
|
||||
proc-macro-warning = { version = "0.4.1", default-features = false }
|
||||
macro_magic = { version = "0.3.5", features = ["proc_support"] }
|
||||
macro_magic = { version = "0.4.1", features = ["proc_support"] }
|
||||
expander = "2.0.0"
|
||||
|
||||
[features]
|
||||
|
||||
@@ -37,6 +37,7 @@ mod storage_alias;
|
||||
mod transactional;
|
||||
mod tt_macro;
|
||||
|
||||
use frame_support_procedural_tools::generate_crate_access_2018;
|
||||
use macro_magic::import_tokens_attr;
|
||||
use proc_macro::TokenStream;
|
||||
use quote::{quote, ToTokens};
|
||||
@@ -952,28 +953,6 @@ pub fn storage_alias(_: TokenStream, input: TokenStream) -> TokenStream {
|
||||
///
|
||||
/// # Advanced Usage
|
||||
///
|
||||
/// ## Importing & Re-Exporting
|
||||
///
|
||||
/// Since `#[derive_impl(..)]` is a
|
||||
/// [`macro_magic`](https://docs.rs/macro_magic/latest/macro_magic/)-based attribute macro, special
|
||||
/// care must be taken when importing and re-exporting it. Glob imports will work properly, such as
|
||||
/// `use frame_support::*` to bring `derive_impl` into scope, however any other use statements
|
||||
/// involving `derive_impl` should have
|
||||
/// [`#[macro_magic::use_attr]`](https://docs.rs/macro_magic/latest/macro_magic/attr.use_attr.html)
|
||||
/// attached or your use statement will fail to fully bring the macro into scope.
|
||||
///
|
||||
/// This brings `derive_impl` into scope in the current context:
|
||||
/// ```ignore
|
||||
/// #[use_attr]
|
||||
/// use frame_support::derive_impl;
|
||||
/// ```
|
||||
///
|
||||
/// This brings `derive_impl` into scope and publicly re-exports it from the current context:
|
||||
/// ```ignore
|
||||
/// #[use_attr]
|
||||
/// pub use frame_support::derive_impl;
|
||||
/// ```
|
||||
///
|
||||
/// ## Expansion
|
||||
///
|
||||
/// The `#[derive_impl(default_impl_path as disambiguation_path)]` attribute will expand to the
|
||||
@@ -987,7 +966,18 @@ pub fn storage_alias(_: 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(frame_support::macro_magic)]
|
||||
#[import_tokens_attr {
|
||||
format!(
|
||||
"{}::macro_magic",
|
||||
match generate_crate_access_2018("frame-support") {
|
||||
Ok(path) => Ok(path),
|
||||
Err(_) => generate_crate_access_2018("frame"),
|
||||
}
|
||||
.expect("Failed to find either `frame-support` or `frame` in `Cargo.toml` dependencies.")
|
||||
.to_token_stream()
|
||||
.to_string()
|
||||
)
|
||||
}]
|
||||
#[with_custom_parsing(derive_impl::DeriveImplAttrArgs)]
|
||||
#[proc_macro_attribute]
|
||||
pub fn derive_impl(attrs: TokenStream, input: TokenStream) -> TokenStream {
|
||||
@@ -1034,8 +1024,41 @@ pub fn no_default(_: TokenStream, _: TokenStream) -> TokenStream {
|
||||
/// type MaxConsumers = frame_support::traits::ConstU32<16>;
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// ## Advanced Usage
|
||||
///
|
||||
/// This macro acts as a thin wrapper around macro_magic's `#[export_tokens]`. See the docs
|
||||
/// [here](https://docs.rs/macro_magic/latest/macro_magic/attr.export_tokens.html) for more info.
|
||||
/// [here](https://docs.rs/macro_magic/latest/macro_magic/attr.export_tokens.html) for more
|
||||
/// info.
|
||||
///
|
||||
/// There are some caveats when applying a `use` statement to bring a
|
||||
/// `#[register_default_impl]` item into scope. If you have a `#[register_default_impl]`
|
||||
/// defined in `my_crate::submodule::MyItem`, it is currently not sufficient to do something
|
||||
/// like:
|
||||
///
|
||||
/// ```ignore
|
||||
/// use my_crate::submodule::MyItem;
|
||||
/// #[derive_impl(MyItem as Whatever)]
|
||||
/// ```
|
||||
///
|
||||
/// This will fail with a mysterious message about `__export_tokens_tt_my_item` not being
|
||||
/// defined.
|
||||
///
|
||||
/// You can, however, do any of the following:
|
||||
/// ```ignore
|
||||
/// // partial path works
|
||||
/// use my_crate::submodule;
|
||||
/// #[derive_impl(submodule::MyItem as Whatever)]
|
||||
/// ```
|
||||
/// ```ignore
|
||||
/// // full path works
|
||||
/// #[derive_impl(my_crate::submodule::MyItem as Whatever)]
|
||||
/// ```
|
||||
/// ```ignore
|
||||
/// // wild-cards work
|
||||
/// use my_crate::submodule::*;
|
||||
/// #[derive_impl(MyItem as Whatever)]
|
||||
/// ```
|
||||
#[proc_macro_attribute]
|
||||
pub fn register_default_impl(attrs: TokenStream, tokens: TokenStream) -> TokenStream {
|
||||
// ensure this is a impl statement
|
||||
|
||||
@@ -210,7 +210,6 @@ impl TypeId for PalletId {
|
||||
/// ```
|
||||
pub use frame_support_procedural::storage_alias;
|
||||
|
||||
#[macro_magic::use_attr]
|
||||
pub use frame_support_procedural::derive_impl;
|
||||
|
||||
/// Create new implementations of the [`Get`](crate::traits::Get) trait.
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
error: expected `impl`
|
||||
--> tests/derive_impl_ui/attached_to_non_impl.rs:24:1
|
||||
--> tests/derive_impl_ui/attached_to_non_impl.rs:39:1
|
||||
|
|
||||
24 | / #[register_default_impl(FourLeggedAnimal)]
|
||||
25 | | impl Animal for FourLeggedAnimal {
|
||||
26 | | type Locomotion = RunsOnFourLegs;
|
||||
27 | | type Diet = Omnivore;
|
||||
... |
|
||||
37 | |
|
||||
38 | | #[derive_impl(FourLeggedAnimal as Animal)]
|
||||
| |_-----------------------------------------^
|
||||
| |
|
||||
| in this procedural macro expansion
|
||||
|
|
||||
= note: this error originates in the macro `__import_tokens_attr_derive_impl_inner` which comes from the expansion of the attribute macro `derive_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
39 | struct Something {}
|
||||
| ^^^^^^
|
||||
|
||||
@@ -1,16 +1,5 @@
|
||||
error[E0433]: failed to resolve: use of undeclared type `Insect`
|
||||
--> tests/derive_impl_ui/bad_disambiguation_path.rs:24:1
|
||||
--> tests/derive_impl_ui/bad_disambiguation_path.rs:38:35
|
||||
|
|
||||
24 | / #[register_default_impl(FourLeggedAnimal)]
|
||||
25 | | impl Animal for FourLeggedAnimal {
|
||||
26 | | type Locomotion = RunsOnFourLegs;
|
||||
27 | | type Diet = Omnivore;
|
||||
... |
|
||||
37 | |
|
||||
38 | | #[derive_impl(FourLeggedAnimal as Insect)]
|
||||
| | -----------------------------------------^
|
||||
| |_|________________________________________|
|
||||
| | use of undeclared type `Insect`
|
||||
| in this procedural macro expansion
|
||||
|
|
||||
= note: this error originates in the macro `__import_tokens_attr_derive_impl_inner` which comes from the expansion of the attribute macro `derive_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
38 | #[derive_impl(FourLeggedAnimal as Insect)]
|
||||
| ^^^^^^ use of undeclared type `Insect`
|
||||
|
||||
Reference in New Issue
Block a user