summaryrefslogtreecommitdiffstats
path: root/tokio/tests
diff options
context:
space:
mode:
authorAlice Ryhl <alice@ryhl.io>2020-04-12 23:55:37 +0200
committerGitHub <noreply@github.com>2020-04-12 14:55:37 -0700
commit4fc2adae4fcc76fa8ff1169fed3db6d7c9100c4a (patch)
treecd69f0a7a853655c190e9a4474b66e2604a6ab88 /tokio/tests
parentf39c15334e74b07a44efaa0f7201262e17e4f062 (diff)
task: make LocalSet non-Send (#2398)
This does not count as a breaking change as it fixes a regression and a soundness bug.
Diffstat (limited to 'tokio/tests')
-rw-r--r--tokio/tests/async_send_sync.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/tokio/tests/async_send_sync.rs b/tokio/tests/async_send_sync.rs
index f50b41a0..1fea19c2 100644
--- a/tokio/tests/async_send_sync.rs
+++ b/tokio/tests/async_send_sync.rs
@@ -41,6 +41,44 @@ macro_rules! into_todo {
x
}};
}
+macro_rules! assert_value {
+ ($type:ty: Send & Sync) => {
+ #[allow(unreachable_code)]
+ #[allow(unused_variables)]
+ const _: fn() = || {
+ let f: $type = todo!();
+ require_send(&f);
+ require_sync(&f);
+ };
+ };
+ ($type:ty: !Send & Sync) => {
+ #[allow(unreachable_code)]
+ #[allow(unused_variables)]
+ const _: fn() = || {
+ let f: $type = todo!();
+ AmbiguousIfSend::some_item(&f);
+ require_sync(&f);
+ };
+ };
+ ($type:ty: Send & !Sync) => {
+ #[allow(unreachable_code)]
+ #[allow(unused_variables)]
+ const _: fn() = || {
+ let f: $type = todo!();
+ require_send(&f);
+ AmbiguousIfSync::some_item(&f);
+ };
+ };
+ ($type:ty: !Send & !Sync) => {
+ #[allow(unreachable_code)]
+ #[allow(unused_variables)]
+ const _: fn() = || {
+ let f: $type = todo!();
+ AmbiguousIfSend::some_item(&f);
+ AmbiguousIfSync::some_item(&f);
+ };
+ };
+}
macro_rules! async_assert_fn {
($($f:ident $(< $($generic:ty),* > )? )::+($($arg:ty),*): Send & Sync) => {
#[allow(unreachable_code)]
@@ -206,6 +244,7 @@ async_assert_fn!(tokio::task::LocalKey<Rc<u32>>::scope(_, Rc<u32>, BoxFutureSync
async_assert_fn!(tokio::task::LocalKey<Rc<u32>>::scope(_, Rc<u32>, BoxFutureSend<()>): !Send & !Sync);
async_assert_fn!(tokio::task::LocalKey<Rc<u32>>::scope(_, Rc<u32>, BoxFuture<()>): !Send & !Sync);
async_assert_fn!(tokio::task::LocalSet::run_until(_, BoxFutureSync<()>): !Send & !Sync);
+assert_value!(tokio::task::LocalSet: !Send & !Sync);
async_assert_fn!(tokio::time::advance(Duration): Send & Sync);
async_assert_fn!(tokio::time::delay_for(Duration): Send & Sync);