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 expected `impl Future<Output = u8>` to be a future that resolves to `()`, but it resolves to `u8`
21 async fn return_targets_async_block_not_async_fn() -> u8 {
22 //~^ ERROR mismatched types [E0308]
26 let _: &dyn Future<Output = ()> = █
27 //~^ ERROR expected `impl Future<Output = u8>` to be a future that resolves to `()`, but it resolves to `u8`
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> {
49 fn rethrow_targets_async_block_not_fn() -> Result<u8, MyErr> {
50 //~^ ERROR mismatched types
55 let _: &dyn Future<Output = Result<(), MyErr>> = █
58 fn rethrow_targets_async_block_not_async_fn() -> Result<u8, MyErr> {
59 //~^ ERROR mismatched types
64 let _: &dyn Future<Output = Result<(), MyErr>> = █