Run cargo fmt on the whole code base (#9394)

* Run cargo fmt on the whole code base

* Second run

* Add CI check

* Fix compilation

* More unnecessary braces

* Handle weights

* Use --all

* Use correct attributes...

* Fix UI tests

* AHHHHHHHHH

* 🤦

* Docs

* Fix compilation

* 🤷

* Please stop

* 🤦 x 2

* More

* make rustfmt.toml consistent with polkadot

Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
Bastian Köcher
2021-07-21 16:32:32 +02:00
committed by GitHub
parent d451c38c1c
commit 7b56ab15b4
1010 changed files with 53339 additions and 51208 deletions
+38 -16
View File
@@ -17,9 +17,9 @@
//! Smaller traits used in FRAME which don't need their own file.
use sp_runtime::{traits::Block as BlockT, DispatchError};
use sp_arithmetic::traits::AtLeast32Bit;
use crate::dispatch::Parameter;
use sp_arithmetic::traits::AtLeast32Bit;
use sp_runtime::{traits::Block as BlockT, DispatchError};
/// Anything that can have a `::len()` method.
pub trait Len {
@@ -27,7 +27,10 @@ pub trait Len {
fn len(&self) -> usize;
}
impl<T: IntoIterator + Clone,> Len for T where <T as IntoIterator>::IntoIter: ExactSizeIterator {
impl<T: IntoIterator + Clone> Len for T
where
<T as IntoIterator>::IntoIter: ExactSizeIterator,
{
fn len(&self) -> usize {
self.clone().into_iter().len()
}
@@ -42,7 +45,9 @@ pub trait Get<T> {
}
impl<T: Default> Get<T> for () {
fn get() -> T { T::default() }
fn get() -> T {
T::default()
}
}
/// Implement Get by returning Default for any type that implements Default.
@@ -123,7 +128,10 @@ impl<A, B> SameOrOther<A, B> {
}
}
pub fn same(self) -> Result<A, B> where A: Default {
pub fn same(self) -> Result<A, B>
where
A: Default,
{
match self {
SameOrOther::Same(a) => Ok(a),
SameOrOther::None => Ok(A::default()),
@@ -131,7 +139,10 @@ impl<A, B> SameOrOther<A, B> {
}
}
pub fn other(self) -> Result<B, A> where B: Default {
pub fn other(self) -> Result<B, A>
where
B: Default,
{
match self {
SameOrOther::Same(a) => Err(a),
SameOrOther::None => Ok(B::default()),
@@ -157,10 +168,14 @@ pub trait OnKilledAccount<AccountId> {
/// A simple, generic one-parameter event notifier/handler.
pub trait HandleLifetime<T> {
/// An account was created.
fn created(_t: &T) -> Result<(), DispatchError> { Ok(()) }
fn created(_t: &T) -> Result<(), DispatchError> {
Ok(())
}
/// An account was killed.
fn killed(_t: &T) -> Result<(), DispatchError> { Ok(()) }
fn killed(_t: &T) -> Result<(), DispatchError> {
Ok(())
}
}
impl<T> HandleLifetime<T> for () {}
@@ -195,10 +210,18 @@ pub trait IsType<T>: Into<T> + From<T> {
}
impl<T> IsType<T> for T {
fn from_ref(t: &T) -> &Self { t }
fn into_ref(&self) -> &T { self }
fn from_mut(t: &mut T) -> &mut Self { t }
fn into_mut(&mut self) -> &mut T { self }
fn from_ref(t: &T) -> &Self {
t
}
fn into_ref(&self) -> &T {
self
}
fn from_mut(t: &mut T) -> &mut Self {
t
}
fn into_mut(&mut self) -> &mut T {
self
}
}
/// Something that can be checked to be a of sub type `T`.
@@ -300,8 +323,6 @@ pub trait GetBacking {
fn get_backing(&self) -> Option<Backing>;
}
/// A trait to ensure the inherent are before non-inherent in a block.
///
/// This is typically implemented on runtime, through `construct_runtime!`.
@@ -319,7 +340,8 @@ pub trait ExtrinsicCall: sp_runtime::traits::Extrinsic {
}
#[cfg(feature = "std")]
impl<Call, Extra> ExtrinsicCall for sp_runtime::testing::TestXt<Call, Extra> where
impl<Call, Extra> ExtrinsicCall for sp_runtime::testing::TestXt<Call, Extra>
where
Call: codec::Codec + Sync + Send,
{
fn call(&self) -> &Self::Call {
@@ -328,7 +350,7 @@ impl<Call, Extra> ExtrinsicCall for sp_runtime::testing::TestXt<Call, Extra> whe
}
impl<Address, Call, Signature, Extra> ExtrinsicCall
for sp_runtime::generic::UncheckedExtrinsic<Address, Call, Signature, Extra>
for sp_runtime::generic::UncheckedExtrinsic<Address, Call, Signature, Extra>
where
Extra: sp_runtime::traits::SignedExtension,
{