]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/match-prev-arm-needing-semi.rs
Merge commit '1d8491b120223272b13451fc81265aa64f7f4d5b' into sync-from-rustfmt
[rust.git] / tests / ui / suggestions / match-prev-arm-needing-semi.rs
1 // edition:2018
2
3 fn dummy() -> i32 { 42 }
4
5 fn extra_semicolon() {
6     let _ = match true { //~ NOTE `match` arms have incompatible types
7         true => {
8             dummy(); //~ NOTE this is found to be
9             //~^ HELP consider removing this semicolon
10         }
11         false => dummy(), //~ ERROR `match` arms have incompatible types
12         //~^ NOTE expected `()`, found `i32`
13     };
14 }
15
16 async fn async_dummy() {} //~ NOTE checked the `Output` of this `async fn`, found opaque type
17 //~| NOTE while checking the return type of the `async fn`
18 //~| NOTE in this expansion of desugaring of `async` block or function
19 //~| NOTE checked the `Output` of this `async fn`, expected opaque type
20 //~| NOTE while checking the return type of the `async fn`
21 //~| NOTE in this expansion of desugaring of `async` block or function
22 async fn async_dummy2() {} //~ NOTE checked the `Output` of this `async fn`, found opaque type
23 //~| NOTE checked the `Output` of this `async fn`, found opaque type
24 //~| NOTE while checking the return type of the `async fn`
25 //~| NOTE in this expansion of desugaring of `async` block or function
26 //~| NOTE while checking the return type of the `async fn`
27 //~| NOTE in this expansion of desugaring of `async` block or function
28
29 async fn async_extra_semicolon_same() {
30     let _ = match true { //~ NOTE `match` arms have incompatible types
31         true => {
32             async_dummy(); //~ NOTE this is found to be
33             //~^ HELP consider removing this semicolon
34         }
35         false => async_dummy(), //~ ERROR `match` arms have incompatible types
36         //~^ NOTE expected `()`, found opaque type
37         //~| NOTE expected unit type `()`
38         //~| HELP consider `await`ing on the `Future`
39     };
40 }
41
42 async fn async_extra_semicolon_different() {
43     let _ = match true { //~ NOTE `match` arms have incompatible types
44         true => {
45             async_dummy(); //~ NOTE this is found to be
46             //~^ HELP consider removing this semicolon
47         }
48         false => async_dummy2(), //~ ERROR `match` arms have incompatible types
49         //~^ NOTE expected `()`, found opaque type
50         //~| NOTE expected unit type `()`
51         //~| HELP consider `await`ing on the `Future`
52     };
53 }
54
55 async fn async_different_futures() {
56     let _ = match true { //~ NOTE `match` arms have incompatible types
57         true => async_dummy(), //~ NOTE this is found to be
58         //~| HELP consider `await`ing on both `Future`s
59         false => async_dummy2(), //~ ERROR `match` arms have incompatible types
60         //~^ NOTE expected opaque type, found a different opaque type
61         //~| NOTE expected opaque type `impl Future<Output = ()>`
62         //~| NOTE distinct uses of `impl Trait` result in different opaque types
63     };
64 }
65
66 fn main() {}