]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.rs
Rollup merge of #107306 - compiler-errors:correct-sugg-for-closure-arg-needs-borrow...
[rust.git] / tests / ui / borrowck / issue-54499-field-mutation-of-moved-out-with-mut.rs
1 #![warn(unused)]
2 #[derive(Debug)]
3 struct S(i32);
4
5 type Tuple = (S, i32);
6 struct Tpair(S, i32);
7 struct Spair { x: S, y: i32 }
8
9 fn main() {
10     {
11         let mut t: Tuple = (S(0), 0);
12         drop(t);
13         t.0 = S(1);
14         //~^ ERROR assign to part of moved value
15         t.1 = 2;
16         println!("{:?} {:?}", t.0, t.1);
17     }
18
19     {
20         let mut u: Tpair = Tpair(S(0), 0);
21         drop(u);
22         u.0 = S(1);
23         //~^ ERROR assign to part of moved value
24         u.1 = 2;
25         println!("{:?} {:?}", u.0, u.1);
26     }
27
28     {
29         let mut v: Spair = Spair { x: S(0), y: 0 };
30         drop(v);
31         v.x = S(1);
32         //~^ ERROR assign to part of moved value
33         v.y = 2;
34         println!("{:?} {:?}", v.x, v.y);
35     }
36 }