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