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
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::{InherentData, Error, InherentIdentifier};
use crate::{Error, InherentData, InherentIdentifier};
use sp_runtime::traits::Block as BlockT;
/// Something that can create inherent data providers.
@@ -44,7 +44,9 @@ impl<F, Block, IDP, ExtraArgs, Fut> CreateInherentDataProviders<Block, ExtraArgs
where
Block: BlockT,
F: Fn(Block::Hash, ExtraArgs) -> Fut + Sync + Send,
Fut: std::future::Future<Output = Result<IDP, Box<dyn std::error::Error + Send + Sync>>> + Send + 'static,
Fut: std::future::Future<Output = Result<IDP, Box<dyn std::error::Error + Send + Sync>>>
+ Send
+ 'static,
IDP: InherentDataProvider + 'static,
ExtraArgs: Send + 'static,
{
+18 -29
View File
@@ -140,7 +140,7 @@
//! let block_production = if is_validator {
//! // For block production we want to provide our inherent data provider
//! cool_consensus_block_production(|_parent, ()| async {
//! Ok(InherentDataProvider)
//! Ok(InherentDataProvider)
//! }).boxed()
//! } else {
//! futures::future::pending().boxed()
@@ -162,9 +162,12 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_docs)]
use codec::{Encode, Decode};
use codec::{Decode, Encode};
use sp_std::{collections::btree_map::{BTreeMap, IntoIter, Entry}, vec::Vec};
use sp_std::{
collections::btree_map::{BTreeMap, Entry, IntoIter},
vec::Vec,
};
#[cfg(feature = "std")]
mod client_side;
@@ -204,7 +207,7 @@ pub type InherentIdentifier = [u8; 8];
#[derive(Clone, Default, Encode, Decode)]
pub struct InherentData {
/// All inherent data encoded with parity-scale-codec and an identifier.
data: BTreeMap<InherentIdentifier, Vec<u8>>
data: BTreeMap<InherentIdentifier, Vec<u8>>,
}
impl InherentData {
@@ -231,20 +234,14 @@ impl InherentData {
entry.insert(inherent.encode());
Ok(())
},
Entry::Occupied(_) => {
Err(Error::InherentDataExists(identifier))
}
Entry::Occupied(_) => Err(Error::InherentDataExists(identifier)),
}
}
/// Replace the data for an inherent.
///
/// If it does not exist, the data is just inserted.
pub fn replace_data<I: codec::Encode>(
&mut self,
identifier: InherentIdentifier,
inherent: &I,
) {
pub fn replace_data<I: codec::Encode>(&mut self, identifier: InherentIdentifier, inherent: &I) {
self.data.insert(identifier, inherent.encode());
}
@@ -260,11 +257,10 @@ impl InherentData {
identifier: &InherentIdentifier,
) -> Result<Option<I>, Error> {
match self.data.get(identifier) {
Some(inherent) =>
I::decode(&mut &inherent[..])
.map_err(|e| Error::DecodingFailed(e, *identifier))
.map(Some),
None => Ok(None)
Some(inherent) => I::decode(&mut &inherent[..])
.map_err(|e| Error::DecodingFailed(e, *identifier))
.map(Some),
None => Ok(None),
}
}
@@ -292,11 +288,7 @@ pub struct CheckInherentsResult {
impl Default for CheckInherentsResult {
fn default() -> Self {
Self {
okay: true,
errors: InherentData::new(),
fatal_error: false,
}
Self { okay: true, errors: InherentData::new(), fatal_error: false }
}
}
@@ -370,8 +362,8 @@ impl CheckInherentsResult {
impl PartialEq for CheckInherentsResult {
fn eq(&self, other: &Self) -> bool {
self.fatal_error == other.fatal_error &&
self.okay == other.okay &&
self.errors.data == other.errors.data
self.okay == other.okay &&
self.errors.data == other.errors.data
}
}
@@ -407,7 +399,7 @@ impl<E: codec::Encode> IsFatalError for MakeFatalError<E> {
#[cfg(test)]
mod tests {
use super::*;
use codec::{Encode, Decode};
use codec::{Decode, Encode};
const TEST_INHERENT_0: InherentIdentifier = *b"testinh0";
const TEST_INHERENT_1: InherentIdentifier = *b"testinh1";
@@ -470,10 +462,7 @@ mod tests {
let inherent_data = provider.create_inherent_data().unwrap();
assert_eq!(
inherent_data.get_data::<u32>(&TEST_INHERENT_0).unwrap().unwrap(),
42u32,
);
assert_eq!(inherent_data.get_data::<u32>(&TEST_INHERENT_0).unwrap().unwrap(), 42u32,);
}
#[test]