From e6a4bb1be6dc37f9b11e4a0bdb5e2d183177aa5f Mon Sep 17 00:00:00 2001 From: thiolliere Date: Tue, 26 Mar 2019 10:44:01 +0100 Subject: [PATCH] fix macro internal use with $crate (#2060) --- substrate/srml/support/src/dispatch.rs | 28 +++++++++---------- substrate/srml/support/src/runtime.rs | 10 +++---- substrate/srml/support/test/tests/instance.rs | 22 +++++++-------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/substrate/srml/support/src/dispatch.rs b/substrate/srml/support/src/dispatch.rs index 10ef979b61..c85415b25c 100644 --- a/substrate/srml/support/src/dispatch.rs +++ b/substrate/srml/support/src/dispatch.rs @@ -110,7 +110,7 @@ macro_rules! decl_module { $($t:tt)* } ) => { - decl_module!(@normalize + $crate::decl_module!(@normalize $(#[$attr])* pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = system @@ -129,7 +129,7 @@ macro_rules! decl_module { $($t:tt)* } ) => { - decl_module!(@normalize + $crate::decl_module!(@normalize $(#[$attr])* pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system @@ -155,7 +155,7 @@ macro_rules! decl_module { $vis:vis fn deposit_event $(<$dpeg:ident $(, $dpeg_instance:ident)?>)* () = default; $($rest:tt)* ) => { - decl_module!(@normalize + $crate::decl_module!(@normalize $(#[$attr])* pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system @@ -182,7 +182,7 @@ macro_rules! decl_module { ) { $( $impl:tt )* } $($rest:tt)* ) => { - decl_module!(@normalize + $crate::decl_module!(@normalize $(#[$attr])* pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system @@ -207,7 +207,7 @@ macro_rules! decl_module { fn on_finalise($($param_name:ident : $param:ty),* ) { $( $impl:tt )* } $($rest:tt)* ) => { - decl_module!(@normalize + $crate::decl_module!(@normalize $(#[$attr])* pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system @@ -232,7 +232,7 @@ macro_rules! decl_module { fn on_initialise($($param_name:ident : $param:ty),* ) { $( $impl:tt )* } $($rest:tt)* ) => { - decl_module!(@normalize + $crate::decl_module!(@normalize $(#[$attr])* pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system @@ -284,7 +284,7 @@ macro_rules! decl_module { ) $( -> $result:ty )* { $( $impl:tt )* } $($rest:tt)* ) => { - decl_module!(@normalize + $crate::decl_module!(@normalize $(#[$attr])* pub struct $mod_type<$trait_instance: $trait_name$(, $instance: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system @@ -360,7 +360,7 @@ macro_rules! decl_module { ) $( -> $result:ty )* { $( $impl:tt )* } $($rest:tt)* ) => { - decl_module!(@normalize + $crate::decl_module!(@normalize $(#[$attr])* pub struct $mod_type<$trait_instance: $trait_name$(, $instance: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system @@ -389,7 +389,7 @@ macro_rules! decl_module { { $( $offchain:tt )* } [ $($t:tt)* ] ) => { - decl_module!(@imp + $crate::decl_module!(@imp $(#[$attr])* pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system { @@ -649,25 +649,25 @@ macro_rules! decl_module { #[cfg(not(feature = "std"))] pub struct $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable $( = $module_default_instance)?)?>(::core::marker::PhantomData<($trait_instance $(, $instance)?)>); - decl_module! { + $crate::decl_module! { @impl_on_initialise $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable)?>; $( $on_initialise )* } - decl_module! { + $crate::decl_module! { @impl_on_finalise $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable)?>; $( $on_finalise )* } - decl_module! { + $crate::decl_module! { @impl_offchain $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable)?>; $( $offchain )* } - decl_module! { + $crate::decl_module! { @impl_deposit_event $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable)?>; $system; @@ -679,7 +679,7 @@ macro_rules! decl_module { /// [`Call`]: enum.Call.html impl<$trait_instance: $trait_name $(, $instance: $instantiable)?> $mod_type<$trait_instance $(, $instance)?> { $( - decl_module! { + $crate::decl_module! { @impl_function $mod_type<$trait_instance: $trait_name $(, $fn_instance: $fn_instantiable)?>; $origin_type; diff --git a/substrate/srml/support/src/runtime.rs b/substrate/srml/support/src/runtime.rs index c575383b26..4f402da8d5 100644 --- a/substrate/srml/support/src/runtime.rs +++ b/substrate/srml/support/src/runtime.rs @@ -87,7 +87,7 @@ macro_rules! construct_runtime { $( $rest:tt )* } ) => { - construct_runtime!( + $crate::construct_runtime!( { $runtime; $block; @@ -105,7 +105,7 @@ macro_rules! construct_runtime { $name:ident: $module:ident, $( $rest:tt )* ) => { - construct_runtime!( + $crate::construct_runtime!( { $( $preset )* }; { $( $expanded )* $name: $module::{Module, Call, Storage, Event, Config}, }; $( $rest )* @@ -124,7 +124,7 @@ macro_rules! construct_runtime { }, $( $rest:tt )* ) => { - construct_runtime!( + $crate::construct_runtime!( { $( $preset )* }; { $( $expanded )* @@ -151,7 +151,7 @@ macro_rules! construct_runtime { }, $( $rest:tt )* ) => { - construct_runtime!( + $crate::construct_runtime!( { $( $preset )* }; { $( $expanded )* @@ -177,7 +177,7 @@ macro_rules! construct_runtime { }, $( $rest:tt )* ) => { - construct_runtime!( + $crate::construct_runtime!( { $( $preset )* }; { $( $expanded )* diff --git a/substrate/srml/support/test/tests/instance.rs b/substrate/srml/support/test/tests/instance.rs index 373e3e23d0..6f4effbc1a 100644 --- a/substrate/srml/support/test/tests/instance.rs +++ b/substrate/srml/support/test/tests/instance.rs @@ -24,7 +24,7 @@ use srml_support::rstd as rstd; use srml_support::codec::{Encode, Decode}; use srml_support::runtime_primitives::{generic, BuildStorage}; use srml_support::runtime_primitives::traits::{BlakeTwo256, Block as _, Verify, Digest}; -use srml_support::{Parameter, construct_runtime, decl_module, decl_storage, decl_event}; +use srml_support::Parameter; use inherents::{ ProvideInherent, InherentData, InherentIdentifier, RuntimeString, MakeFatalError }; @@ -50,7 +50,7 @@ mod system { pub type DigestItemOf = <::Digest as Digest>::Item; - decl_module! { + srml_support::decl_module! { pub struct Module for enum Call where origin: T::Origin { pub fn deposit_event(_event: T::Event) { } @@ -62,7 +62,7 @@ mod system { } } - decl_event!( + srml_support::decl_event!( pub enum Event { ExtrinsicSuccess, ExtrinsicFailed, @@ -122,7 +122,7 @@ mod module1 { type Log: From> + Into>; } - decl_module! { + srml_support::decl_module! { pub struct Module, I: InstantiableThing> for enum Call where origin: ::Origin { fn deposit_event() = default; @@ -140,7 +140,7 @@ mod module1 { } } - decl_storage! { + srml_support::decl_storage! { trait Store for Module, I: InstantiableThing> as Module1 { pub Value config(value): u64; pub Map: map u32 => u64; @@ -148,7 +148,7 @@ mod module1 { } } - decl_event! { + srml_support::decl_event! { pub enum Event where Phantom = rstd::marker::PhantomData { _Phantom(Phantom), AnotherVariant(u32), @@ -207,13 +207,13 @@ mod module2 { impl, I: Instance> Currency for Module {} - decl_module! { + srml_support::decl_module! { pub struct Module, I: Instance=DefaultInstance> for enum Call where origin: ::Origin { fn deposit_event() = default; } } - decl_storage! { + srml_support::decl_storage! { trait Store for Module, I: Instance=DefaultInstance> as Module2 { pub Value config(value): T::Amount; pub Map config(map): map u64 => u64; @@ -222,7 +222,7 @@ mod module2 { extra_genesis_skip_phantom_data_field; } - decl_event! { + srml_support::decl_event! { pub enum Event where Amount = >::Amount { Variant(Amount), } @@ -275,7 +275,7 @@ mod module3 { type Currency2: Currency; } - decl_module! { + srml_support::decl_module! { pub struct Module for enum Call where origin: ::Origin { } } @@ -335,7 +335,7 @@ impl system::Trait for Runtime { type Log = Log; } -construct_runtime!( +srml_support::construct_runtime!( pub enum Runtime with Log(InternalLog: DigestItem) where Block = Block, NodeBlock = Block,