1#![deny(unreachable_code)]
2
3use futures::{executor::block_on, try_join};
4
5// TODO: This abuses https://github.com/rust-lang/rust/issues/58733 in order to
6// test behavior of the `try_join!` macro with the never type before it is
7// stabilized. Once `!` is again stabilized this can be removed and replaced
8// with direct use of `!` below where `Never` is used.
9trait MyTrait {
10 type Output;
11}
12impl<T> MyTrait for fn() -> T {
13 type Output = T;
14}
15type Never = <fn() -> ! as MyTrait>::Output;
16
17#[test]
18fn try_join_never_error() {
19 block_on(async {
20 let future1 = async { Ok::<(), Never>(()) };
21 let future2 = async { Ok::<(), Never>(()) };
22 try_join!(future1, future2)
23 })
24 .unwrap();
25}
26
27#[test]
28fn try_join_never_ok() {
29 block_on(async {
30 let future1 = async { Err::<Never, ()>(()) };
31 let future2 = async { Err::<Never, ()>(()) };
32 try_join!(future1, future2)
33 })
34 .unwrap_err();
35}
36