mark runtime as UnwindSafe

An alternative would be to mark bit of state as runtime safe, but as
Runtime directly contains a RefCell we need to mark it as a whole
anyway!
This commit is contained in:
Aleksey Kladov 2019-01-10 12:48:07 +03:00
parent add15d83ea
commit b637e1a9bb
2 changed files with 8 additions and 0 deletions

View file

@ -35,6 +35,8 @@ pub struct Runtime<DB: Database> {
shared_state: Arc<SharedState<DB>>,
}
impl<DB> std::panic::RefUnwindSafe for Runtime<DB> where DB: Database {}
impl<DB> Default for Runtime<DB>
where
DB: Database,

View file

@ -63,3 +63,9 @@ fn should_panic_safely() {
let result = panic::catch_unwind(AssertUnwindSafe(|| db.panic_safely()));
assert!(result.is_ok())
}
#[test]
fn storages_are_unwind_safe() {
fn check_unwind_safe<T: std::panic::UnwindSafe>() {}
check_unwind_safe::<&DatabaseStruct>();
}