Switch to new proc-macro crate for implementing traits for tuples (#3598)

* Switch to new proc-macro crate for implementing traits for tuples

* Switch back to stable `Cargo.lock` format

* Reduce tuple number to match rusts default implementation
This commit is contained in:
Bastian Köcher
2019-09-11 19:10:02 +02:00
committed by GitHub
parent 433d752831
commit d136b8eb81
16 changed files with 139 additions and 306 deletions
@@ -12,6 +12,7 @@ rstd = { package = "sr-std", path = "../../core/sr-std", default-features = fals
sr-primitives = { path = "../../core/sr-primitives", default-features = false }
support = { package = "srml-support", path = "../support", default-features = false }
srml-system = { path = "../system", default-features = false }
impl-trait-for-tuples = "0.1"
[dev-dependencies]
primitives = { package = "substrate-primitives", path = "../../core/primitives", default-features = false }
+2 -19
View File
@@ -26,7 +26,7 @@ use support::StorageValue;
use sr_primitives::traits::{One, Zero, SaturatedConversion};
use rstd::{prelude::*, result, cmp, vec};
use codec::Decode;
use support::{decl_module, decl_storage, for_each_tuple};
use support::{decl_module, decl_storage};
use support::traits::Get;
use srml_system::{ensure_none, Trait as SystemTrait};
@@ -214,30 +214,13 @@ impl<T: Trait> Module<T> {
}
/// Called when finalization stalled at a given number.
#[impl_trait_for_tuples::impl_for_tuples(30)]
pub trait OnFinalizationStalled<N> {
/// The parameter here is how many more blocks to wait before applying
/// changes triggered by finality stalling.
fn on_stalled(further_wait: N, median: N);
}
macro_rules! impl_on_stalled {
() => (
impl<N> OnFinalizationStalled<N> for () {
fn on_stalled(_: N, _: N) {}
}
);
( $($t:ident)* ) => {
impl<NUM: Clone, $($t: OnFinalizationStalled<NUM>),*> OnFinalizationStalled<NUM> for ($($t,)*) {
fn on_stalled(further_wait: NUM, median: NUM) {
$($t::on_stalled(further_wait.clone(), median.clone());)*
}
}
}
}
for_each_tuple!(impl_on_stalled);
impl<T: Trait> ProvideInherent for Module<T> {
type Call = Call<T>;
type Error = MakeFatalError<()>;