]> git.lizzy.rs Git - rust.git/blob - tests/ui/async-await/partial-initialization-across-await.rs
Rollup merge of #107061 - compiler-errors:new-solver-new-candidates-3, r=lcnr
[rust.git] / tests / ui / async-await / partial-initialization-across-await.rs
1 // Test that we don't allow awaiting from an async fn while a local is partially
2 // initialized.
3
4 // edition:2018
5
6 struct S { x: i32, y: i32 }
7 struct T(i32, i32);
8
9 async fn noop() {}
10
11 async fn test_tuple() {
12     let mut t: (i32, i32);
13     t.0 = 42; //~ ERROR E0381
14     noop().await;
15     t.1 = 88;
16     let _ = t;
17 }
18
19 async fn test_tuple_struct() {
20     let mut t: T;
21     t.0 = 42; //~ ERROR E0381
22     noop().await;
23     t.1 = 88;
24     let _ = t;
25 }
26
27 async fn test_struct() {
28     let mut t: S;
29     t.x = 42; //~ ERROR E0381
30     noop().await;
31     t.y = 88;
32     let _ = t;
33 }
34
35 fn main() {
36     let _ = test_tuple();
37     let _ = test_tuple_struct();
38     let _ = test_struct();
39 }