]> git.lizzy.rs Git - rust.git/blob - tests/ui/lint/unused/unused-async.rs
Auto merge of #106989 - clubby789:is-zero-num, r=scottmcm
[rust.git] / tests / ui / lint / unused / unused-async.rs
1 // edition:2018
2 #![deny(unused_must_use)]
3
4
5 #[must_use]
6 async fn foo() -> i32 {
7     1
8 }
9
10 #[must_use]
11 fn bar() -> impl std::future::Future<Output=i32> {
12     async {
13         42
14     }
15 }
16
17 async fn baz() -> i32 {
18     0
19 }
20
21 struct Wowee {}
22
23 impl Wowee {
24     #[must_use]
25     async fn test_method() -> i32 {
26         1
27     }
28 }
29
30 async fn test() {
31     foo(); //~ ERROR unused return value of `foo` that must be used
32     //~^ ERROR unused implementer of `Future` that must be used
33     foo().await; //~ ERROR unused output of future returned by `foo` that must be used
34     bar(); //~ ERROR unused return value of `bar` that must be used
35     //~^ ERROR unused implementer of `Future` that must be used
36     bar().await; //~ ERROR unused output of future returned by `bar` that must be used
37     baz(); //~ ERROR unused implementer of `Future` that must be used
38     baz().await; // ok
39 }
40
41 /* FIXME(guswynn) update this test when async-fn-in-traits works
42 trait Doer {
43     #[must_use]
44     async fn test_trait_method() -> i32;
45     WARNING must_use
46     async fn test_other_trait() -> i32;
47 }
48
49 impl Doer for Wowee {
50     async fn test_trait_method() -> i32 {
51         1
52     }
53     #[must_use]
54     async fn test_other_trait() -> i32 {
55         WARNING must_use
56         1
57     }
58 }
59 */
60
61 fn main() {
62 }