]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generator/partial-initialization-across-yield.rs
Auto merge of #98051 - davidtwco:split-dwarf-stabilization, r=wesleywiser
[rust.git] / src / test / ui / generator / partial-initialization-across-yield.rs
1 // Test that we don't allow yielding from a generator while a local is partially
2 // initialized.
3
4 #![feature(generators)]
5
6 struct S { x: i32, y: i32 }
7 struct T(i32, i32);
8
9 fn test_tuple() {
10     let _ = || {
11         let mut t: (i32, i32);
12         t.0 = 42; //~ ERROR E0381
13         yield;
14         t.1 = 88;
15         let _ = t;
16     };
17 }
18
19 fn test_tuple_struct() {
20     let _ = || {
21         let mut t: T;
22         t.0 = 42; //~ ERROR E0381
23         yield;
24         t.1 = 88;
25         let _ = t;
26     };
27 }
28
29 fn test_struct() {
30     let _ = || {
31         let mut t: S;
32         t.x = 42; //~ ERROR E0381
33         yield;
34         t.y = 88;
35         let _ = t;
36     };
37 }
38
39 fn main() {
40     test_tuple();
41     test_tuple_struct();
42     test_struct();
43 }