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
+1 -1
View File
@@ -26,5 +26,5 @@ pub enum Error {
AllocatorOutOfSpace,
/// Some other error occurred.
#[error("Other: {0}")]
Other(&'static str)
Other(&'static str),
}
+22 -16
View File
@@ -68,8 +68,12 @@
//! sizes.
use crate::Error;
use std::{mem, convert::{TryFrom, TryInto}, ops::{Range, Index, IndexMut}};
use sp_wasm_interface::{Pointer, WordSize};
use std::{
convert::{TryFrom, TryInto},
mem,
ops::{Index, IndexMut, Range},
};
/// The minimal alignment guaranteed by this allocator.
///
@@ -139,7 +143,7 @@ impl Order {
fn from_size(size: u32) -> Result<Self, Error> {
let clamped_size = if size > MAX_POSSIBLE_ALLOCATION {
log::warn!(target: LOG_TARGET, "going to fail due to allocating {:?}", size);
return Err(Error::RequestedAllocationTooLarge);
return Err(Error::RequestedAllocationTooLarge)
} else if size < MIN_POSSIBLE_ALLOCATION {
MIN_POSSIBLE_ALLOCATION
} else {
@@ -216,7 +220,6 @@ impl Link {
/// ```
///
/// ## Occupied header
///
/// ```ignore
/// 64 32 0
// +--------------+-------------------+
@@ -290,9 +293,7 @@ struct FreeLists {
impl FreeLists {
/// Creates the free empty lists.
fn new() -> Self {
Self {
heads: [Link::Nil; N_ORDERS]
}
Self { heads: [Link::Nil; N_ORDERS] }
}
/// Replaces a given link for the specified order and returns the old one.
@@ -397,15 +398,11 @@ impl FreeingBumpHeapAllocator {
self.free_lists[order] = next_free;
header_ptr
}
},
Link::Nil => {
// Corresponding free list is empty. Allocate a new item.
Self::bump(
&mut self.bumper,
order.size() + HEADER_SIZE,
mem.size(),
)?
}
Self::bump(&mut self.bumper, order.size() + HEADER_SIZE, mem.size())?
},
};
// Write the order in the occupied header.
@@ -440,7 +437,11 @@ impl FreeingBumpHeapAllocator {
///
/// - `mem` - a slice representing the linear memory on which this allocator operates.
/// - `ptr` - pointer to the allocated chunk
pub fn deallocate<M: Memory + ?Sized>(&mut self, mem: &mut M, ptr: Pointer<u8>) -> Result<(), Error> {
pub fn deallocate<M: Memory + ?Sized>(
&mut self,
mem: &mut M,
ptr: Pointer<u8>,
) -> Result<(), Error> {
if self.poisoned {
return Err(error("the allocator has been poisoned"))
}
@@ -480,8 +481,13 @@ impl FreeingBumpHeapAllocator {
/// the operation would exhaust the heap.
fn bump(bumper: &mut u32, size: u32, heap_end: u32) -> Result<u32, Error> {
if *bumper + size > heap_end {
log::error!(target: LOG_TARGET, "running out of space with current bumper {}, mem size {}", bumper, heap_end);
return Err(Error::AllocatorOutOfSpace);
log::error!(
target: LOG_TARGET,
"running out of space with current bumper {}, mem size {}",
bumper,
heap_end
);
return Err(Error::AllocatorOutOfSpace)
}
let res = *bumper;
+1 -1
View File
@@ -25,5 +25,5 @@
mod error;
mod freeing_bump;
pub use freeing_bump::FreeingBumpHeapAllocator;
pub use error::Error;
pub use freeing_bump::FreeingBumpHeapAllocator;