1 // Test that `async { .. }` blocks:
2 // 1. do not allow `break` expressions.
3 // 2. get targeted by `return` and not the parent function.
4 // 3. get targeted by `?` and not the parent function.
10 use core::future::Future;
12 fn return_targets_async_block_not_fn() -> u8 {
13 //~^ ERROR mismatched types
17 let _: &dyn Future<Output = ()> = █
18 //~^ ERROR type mismatch resolving `<impl Future as Future>::Output == ()`
21 async fn return_targets_async_block_not_async_fn() -> u8 {
22 //~^ ERROR mismatched types
26 let _: &dyn Future<Output = ()> = █
27 //~^ ERROR type mismatch resolving `<impl Future as Future>::Output == ()`
30 fn no_break_in_async_block() {
32 break 0u8; //~ ERROR `break` inside of an `async` block
36 fn no_break_in_async_block_even_with_outer_loop() {
39 break 0u8; //~ ERROR `break` inside of an `async` block
45 fn err() -> Result<u8, MyErr> { Err(MyErr) }
47 fn rethrow_targets_async_block_not_fn() -> Result<u8, MyErr> {
48 //~^ ERROR mismatched types
53 let _: &dyn Future<Output = Result<(), MyErr>> = █
56 fn rethrow_targets_async_block_not_async_fn() -> Result<u8, MyErr> {
57 //~^ ERROR mismatched types
62 let _: &dyn Future<Output = Result<(), MyErr>> = █