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
+19 -29
View File
@@ -25,11 +25,13 @@
//! temporarily be disabled by using an [`AbortGuard`].
use backtrace::Backtrace;
use std::io::{self, Write};
use std::marker::PhantomData;
use std::panic::{self, PanicInfo};
use std::cell::Cell;
use std::thread;
use std::{
cell::Cell,
io::{self, Write},
marker::PhantomData,
panic::{self, PanicInfo},
thread,
};
thread_local! {
static ON_PANIC: Cell<OnPanic> = Cell::new(OnPanic::Abort);
@@ -56,18 +58,19 @@ pub fn set(bug_url: &str, version: &str) {
panic::set_hook(Box::new({
let version = version.to_string();
let bug_url = bug_url.to_string();
move |c| {
panic_hook(c, &bug_url, &version)
}
move |c| panic_hook(c, &bug_url, &version)
}));
}
macro_rules! ABOUT_PANIC {
() => ("
() => {
"
This is a bug. Please report it at:
{}
")}
"
};
}
/// Set aborting flag. Returns previous value of the flag.
fn set_abort(on_panic: OnPanic) -> OnPanic {
@@ -92,35 +95,26 @@ pub struct AbortGuard {
/// Value that was in `ABORT` before we created this guard.
previous_val: OnPanic,
/// Marker so that `AbortGuard` doesn't implement `Send`.
_not_send: PhantomData<std::rc::Rc<()>>
_not_send: PhantomData<std::rc::Rc<()>>,
}
impl AbortGuard {
/// Create a new guard. While the guard is alive, panics that happen in the current thread will
/// unwind the stack (unless another guard is created afterwards).
pub fn force_unwind() -> AbortGuard {
AbortGuard {
previous_val: set_abort(OnPanic::Unwind),
_not_send: PhantomData
}
AbortGuard { previous_val: set_abort(OnPanic::Unwind), _not_send: PhantomData }
}
/// Create a new guard. While the guard is alive, panics that happen in the current thread will
/// abort the process (unless another guard is created afterwards).
pub fn force_abort() -> AbortGuard {
AbortGuard {
previous_val: set_abort(OnPanic::Abort),
_not_send: PhantomData
}
AbortGuard { previous_val: set_abort(OnPanic::Abort), _not_send: PhantomData }
}
/// Create a new guard. While the guard is alive, panics that happen in the current thread will
/// **never** abort the process (even if `AbortGuard::force_abort()` guard will be created afterwards).
pub fn never_abort() -> AbortGuard {
AbortGuard {
previous_val: set_abort(OnPanic::NeverAbort),
_not_send: PhantomData
}
AbortGuard { previous_val: set_abort(OnPanic::NeverAbort), _not_send: PhantomData }
}
}
@@ -141,7 +135,7 @@ fn panic_hook(info: &PanicInfo, report_url: &str, version: &str) {
None => match info.payload().downcast_ref::<String>() {
Some(s) => &s[..],
None => "Box<Any>",
}
},
};
let thread = thread::current();
@@ -158,11 +152,7 @@ fn panic_hook(info: &PanicInfo, report_url: &str, version: &str) {
let _ = writeln!(stderr, "");
let _ = writeln!(stderr, "{:?}", backtrace);
let _ = writeln!(stderr, "");
let _ = writeln!(
stderr,
"Thread '{}' panicked at '{}', {}:{}",
name, msg, file, line
);
let _ = writeln!(stderr, "Thread '{}' panicked at '{}', {}:{}", name, msg, file, line);
let _ = writeln!(stderr, ABOUT_PANIC!(), report_url);
ON_PANIC.with(|val| {