1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 struct A { a: int, b: Box<int> }
12 struct B { a: Box<int>, b: Box<int> }
14 fn move_after_copy() {
15 let x = A { a: 1, b: box 2 };
20 fn move_after_fu_copy() {
21 let x = A { a: 1, b: box 2 };
22 let _y = A { b: box 3, .. x };
26 fn fu_move_after_copy() {
27 let x = A { a: 1, b: box 2 };
29 let _y = A { a: 3, .. x };
32 fn fu_move_after_fu_copy() {
33 let x = A { a: 1, b: box 2 };
34 let _y = A { b: box 3, .. x };
35 let _z = A { a: 4, .. x };
38 fn copy_after_move() {
39 let x = A { a: 1, b: box 2 };
44 fn copy_after_fu_move() {
45 let x = A { a: 1, b: box 2 };
46 let y = A { a: 3, .. x };
50 fn fu_copy_after_move() {
51 let x = A { a: 1, b: box 2 };
53 let _y = A { b: box 3, .. x };
56 fn fu_copy_after_fu_move() {
57 let x = A { a: 1, b: box 2 };
58 let _y = A { a: 3, .. x };
59 let _z = A { b: box 3, .. x };
62 fn borrow_after_move() {
63 let x = A { a: 1, b: box 2 };
69 fn borrow_after_fu_move() {
70 let x = A { a: 1, b: box 2 };
71 let _y = A { a: 3, .. x };
76 fn move_after_borrow() {
77 let x = A { a: 1, b: box 2 };
83 fn fu_move_after_borrow() {
84 let x = A { a: 1, b: box 2 };
86 let _y = A { a: 3, .. x };
90 fn mut_borrow_after_mut_borrow() {
91 let mut x = A { a: 1, b: box 2 };
98 fn move_after_move() {
99 let x = B { a: box 1, b: box 2 };
104 fn move_after_fu_move() {
105 let x = B { a: box 1, b: box 2 };
106 let y = B { a: box 3, .. x };
110 fn fu_move_after_move() {
111 let x = B { a: box 1, b: box 2 };
113 let z = B { a: box 3, .. x };
117 fn fu_move_after_fu_move() {
118 let x = B { a: box 1, b: box 2 };
119 let _y = B { b: box 3, .. x };
120 let _z = B { a: box 4, .. x };
123 fn copy_after_assign_after_move() {
124 let mut x = A { a: 1, b: box 2 };
126 x = A { a: 3, b: box 4 };
130 fn copy_after_assign_after_fu_move() {
131 let mut x = A { a: 1, b: box 2 };
132 let _y = A { a: 3, .. x };
133 x = A { a: 3, b: box 4 };
137 fn copy_after_field_assign_after_move() {
138 let mut x = A { a: 1, b: box 2 };
144 fn copy_after_field_assign_after_fu_move() {
145 let mut x = A { a: 1, b: box 2 };
146 let _y = A { a: 3, .. x };
151 fn borrow_after_assign_after_move() {
152 let mut x = A { a: 1, b: box 2 };
154 x = A { a: 3, b: box 4 };
159 fn borrow_after_assign_after_fu_move() {
160 let mut x = A { a: 1, b: box 2 };
161 let _y = A { a: 3, .. x };
162 x = A { a: 3, b: box 4 };
167 fn borrow_after_field_assign_after_move() {
168 let mut x = A { a: 1, b: box 2 };
175 fn borrow_after_field_assign_after_fu_move() {
176 let mut x = A { a: 1, b: box 2 };
177 let _y = A { a: 3, .. x };
183 fn move_after_assign_after_move() {
184 let mut x = A { a: 1, b: box 2 };
186 x = A { a: 3, b: box 4 };
190 fn move_after_assign_after_fu_move() {
191 let mut x = A { a: 1, b: box 2 };
192 let _y = A { a: 3, .. x };
193 x = A { a: 3, b: box 4 };
197 fn move_after_field_assign_after_move() {
198 let mut x = A { a: 1, b: box 2 };
204 fn move_after_field_assign_after_fu_move() {
205 let mut x = A { a: 1, b: box 2 };
206 let _y = A { a: 3, .. x };
211 fn copy_after_assign_after_uninit() {
213 x = A { a: 1, b: box 2 };
217 fn borrow_after_assign_after_uninit() {
219 x = A { a: 1, b: box 2 };
224 fn move_after_assign_after_uninit() {
226 x = A { a: 1, b: box 2 };
232 move_after_fu_copy();
233 fu_move_after_copy();
234 fu_move_after_fu_copy();
236 copy_after_fu_move();
237 fu_copy_after_move();
238 fu_copy_after_fu_move();
241 borrow_after_fu_move();
243 fu_move_after_borrow();
244 mut_borrow_after_mut_borrow();
247 move_after_fu_move();
248 fu_move_after_move();
249 fu_move_after_fu_move();
251 copy_after_assign_after_move();
252 copy_after_assign_after_fu_move();
253 copy_after_field_assign_after_move();
254 copy_after_field_assign_after_fu_move();
256 borrow_after_assign_after_move();
257 borrow_after_assign_after_fu_move();
258 borrow_after_field_assign_after_move();
259 borrow_after_field_assign_after_fu_move();
261 move_after_assign_after_move();
262 move_after_assign_after_fu_move();
263 move_after_field_assign_after_move();
264 move_after_field_assign_after_fu_move();
266 copy_after_assign_after_uninit();
267 borrow_after_assign_after_uninit();
268 move_after_assign_after_uninit();