Skip to content

Commit

Permalink
tokio: Fix empty join! and try_join!
Browse files Browse the repository at this point in the history
This closes tokio-rs#5502.
  • Loading branch information
adrianheine committed Feb 25, 2023
1 parent c894069 commit 0b8be26
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tokio/src/macros/join.rs
Expand Up @@ -158,7 +158,9 @@ macro_rules! join {

// ===== Entry point =====

( $($e:expr),* $(,)?) => {
( $($e:expr),+ $(,)?) => {
$crate::join!(@{ () (0) } $($e,)*)
};

() => { async {}.await }
}
4 changes: 3 additions & 1 deletion tokio/src/macros/try_join.rs
Expand Up @@ -210,7 +210,9 @@ macro_rules! try_join {

// ===== Entry point =====

( $($e:expr),* $(,)?) => {
( $($e:expr),+ $(,)?) => {
$crate::try_join!(@{ () (0) } $($e,)*)
};

() => { async { Ok(()) }.await }
}
5 changes: 5 additions & 0 deletions tokio/tests/macros_join.rs
Expand Up @@ -153,3 +153,8 @@ async fn a_different_future_is_polled_first_every_time_poll_fn_is_polled() {
*poll_order.lock().unwrap()
);
}

#[tokio::test]
async fn empty_join() {
assert_eq!(tokio::join!(), ());
}
5 changes: 5 additions & 0 deletions tokio/tests/macros_try_join.rs
Expand Up @@ -183,3 +183,8 @@ async fn a_different_future_is_polled_first_every_time_poll_fn_is_polled() {
*poll_order.lock().unwrap()
);
}

#[tokio::test]
async fn empty_try_join() {
assert_eq!(tokio::try_join!() as Result<_, ()>, Ok(()));
}

0 comments on commit 0b8be26

Please sign in to comment.