macros: fix empty join! and try_join! (#5504)

Fixes: #5502
This commit is contained in:
Adrian Heine né Lang
2023-02-25 18:06:17 +01:00
committed by GitHub
parent c89406965f
commit ca9f7ee9f4
4 changed files with 17 additions and 2 deletions
+3 -1
View File
@@ -158,7 +158,9 @@ macro_rules! join {
// ===== Entry point =====
( $($e:expr),* $(,)?) => {
( $($e:expr),+ $(,)?) => {
$crate::join!(@{ () (0) } $($e,)*)
};
() => { async {}.await }
}
+3 -1
View File
@@ -210,7 +210,9 @@ macro_rules! try_join {
// ===== Entry point =====
( $($e:expr),* $(,)?) => {
( $($e:expr),+ $(,)?) => {
$crate::try_join!(@{ () (0) } $($e,)*)
};
() => { async { Ok(()) }.await }
}
+6
View File
@@ -153,3 +153,9 @@ async fn a_different_future_is_polled_first_every_time_poll_fn_is_polled() {
*poll_order.lock().unwrap()
);
}
#[tokio::test]
#[allow(clippy::unit_cmp)]
async fn empty_join() {
assert_eq!(tokio::join!(), ());
}
+5
View File
@@ -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(()));
}