Make tokio::run panic if called from inside tokio::run (#646)

This is implemented by creating an `Enter` instance from within `run`.

This patch also introduces `Enter::block_on`.

Fixes #504
This commit is contained in:
Eliza Weisman
2018-09-18 21:57:21 -07:00
committed by Carl Lerche
parent 85f8522536
commit 98d23b8b29
3 changed files with 25 additions and 1 deletions
+12
View File
@@ -390,3 +390,15 @@ mod from_block_on_all {
test(|f| { tokio::spawn(f); })
}
}
#[test]
fn run_in_run() {
use std::panic;
tokio::run(lazy(|| {
panic::catch_unwind(|| {
tokio::run(lazy(|| { Ok::<(), ()>(()) }))
}).unwrap_err();
Ok::<(), ()>(())
}));
}