]> git.proxmox.com Git - rustc.git/blob - src/test/ui/borrowck/borrowck-field-sensitivity-rpass.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / borrowck / borrowck-field-sensitivity-rpass.rs
1 // run-pass
2 #![allow(unused_mut)]
3 #![allow(unused_variables)]
4 // pretty-expanded FIXME #23616
5
6 struct A { a: isize, b: Box<isize> }
7 struct B { a: Box<isize>, b: Box<isize> }
8
9 fn move_after_copy() {
10 let x = A { a: 1, b: Box::new(2) };
11 drop(x.a);
12 drop(x.b);
13 }
14
15 fn move_after_fu_copy() {
16 let x = A { a: 1, b: Box::new(2) };
17 let _y = A { b: Box::new(3), .. x };
18 drop(x.b);
19 }
20
21 fn fu_move_after_copy() {
22 let x = A { a: 1, b: Box::new(2) };
23 drop(x.a);
24 let _y = A { a: 3, .. x };
25 }
26
27 fn fu_move_after_fu_copy() {
28 let x = A { a: 1, b: Box::new(2) };
29 let _y = A { b: Box::new(3), .. x };
30 let _z = A { a: 4, .. x };
31 }
32
33 fn copy_after_move() {
34 let x = A { a: 1, b: Box::new(2) };
35 drop(x.b);
36 drop(x.a);
37 }
38
39 fn copy_after_fu_move() {
40 let x = A { a: 1, b: Box::new(2) };
41 let y = A { a: 3, .. x };
42 drop(x.a);
43 }
44
45 fn fu_copy_after_move() {
46 let x = A { a: 1, b: Box::new(2) };
47 drop(x.b);
48 let _y = A { b: Box::new(3), .. x };
49 }
50
51 fn fu_copy_after_fu_move() {
52 let x = A { a: 1, b: Box::new(2) };
53 let _y = A { a: 3, .. x };
54 let _z = A { b: Box::new(3), .. x };
55 }
56
57 fn borrow_after_move() {
58 let x = A { a: 1, b: Box::new(2) };
59 drop(x.b);
60 let p = &x.a;
61 drop(*p);
62 }
63
64 fn borrow_after_fu_move() {
65 let x = A { a: 1, b: Box::new(2) };
66 let _y = A { a: 3, .. x };
67 let p = &x.a;
68 drop(*p);
69 }
70
71 fn move_after_borrow() {
72 let x = A { a: 1, b: Box::new(2) };
73 let p = &x.a;
74 drop(x.b);
75 drop(*p);
76 }
77
78 fn fu_move_after_borrow() {
79 let x = A { a: 1, b: Box::new(2) };
80 let p = &x.a;
81 let _y = A { a: 3, .. x };
82 drop(*p);
83 }
84
85 fn mut_borrow_after_mut_borrow() {
86 let mut x = A { a: 1, b: Box::new(2) };
87 let p = &mut x.a;
88 let q = &mut x.b;
89 drop(*p);
90 drop(**q);
91 }
92
93 fn move_after_move() {
94 let x = B { a: Box::new(1), b: Box::new(2) };
95 drop(x.a);
96 drop(x.b);
97 }
98
99 fn move_after_fu_move() {
100 let x = B { a: Box::new(1), b: Box::new(2) };
101 let y = B { a: Box::new(3), .. x };
102 drop(x.a);
103 }
104
105 fn fu_move_after_move() {
106 let x = B { a: Box::new(1), b: Box::new(2) };
107 drop(x.a);
108 let z = B { a: Box::new(3), .. x };
109 drop(z.b);
110 }
111
112 fn fu_move_after_fu_move() {
113 let x = B { a: Box::new(1), b: Box::new(2) };
114 let _y = B { b: Box::new(3), .. x };
115 let _z = B { a: Box::new(4), .. x };
116 }
117
118 fn copy_after_assign_after_move() {
119 let mut x = A { a: 1, b: Box::new(2) };
120 drop(x.b);
121 x = A { a: 3, b: Box::new(4) };
122 drop(*x.b);
123 }
124
125 fn copy_after_assign_after_fu_move() {
126 let mut x = A { a: 1, b: Box::new(2) };
127 let _y = A { a: 3, .. x };
128 x = A { a: 3, b: Box::new(4) };
129 drop(*x.b);
130 }
131
132 fn copy_after_field_assign_after_move() {
133 let mut x = A { a: 1, b: Box::new(2) };
134 drop(x.b);
135 x.b = Box::new(3);
136 drop(*x.b);
137 }
138
139 fn copy_after_field_assign_after_fu_move() {
140 let mut x = A { a: 1, b: Box::new(2) };
141 let _y = A { a: 3, .. x };
142 x.b = Box::new(3);
143 drop(*x.b);
144 }
145
146 fn borrow_after_assign_after_move() {
147 let mut x = A { a: 1, b: Box::new(2) };
148 drop(x.b);
149 x = A { a: 3, b: Box::new(4) };
150 let p = &x.b;
151 drop(**p);
152 }
153
154 fn borrow_after_assign_after_fu_move() {
155 let mut x = A { a: 1, b: Box::new(2) };
156 let _y = A { a: 3, .. x };
157 x = A { a: 3, b: Box::new(4) };
158 let p = &x.b;
159 drop(**p);
160 }
161
162 fn borrow_after_field_assign_after_move() {
163 let mut x = A { a: 1, b: Box::new(2) };
164 drop(x.b);
165 x.b = Box::new(3);
166 let p = &x.b;
167 drop(**p);
168 }
169
170 fn borrow_after_field_assign_after_fu_move() {
171 let mut x = A { a: 1, b: Box::new(2) };
172 let _y = A { a: 3, .. x };
173 x.b = Box::new(3);
174 let p = &x.b;
175 drop(**p);
176 }
177
178 fn move_after_assign_after_move() {
179 let mut x = A { a: 1, b: Box::new(2) };
180 let _y = x.b;
181 x = A { a: 3, b: Box::new(4) };
182 drop(x.b);
183 }
184
185 fn move_after_assign_after_fu_move() {
186 let mut x = A { a: 1, b: Box::new(2) };
187 let _y = A { a: 3, .. x };
188 x = A { a: 3, b: Box::new(4) };
189 drop(x.b);
190 }
191
192 fn move_after_field_assign_after_move() {
193 let mut x = A { a: 1, b: Box::new(2) };
194 drop(x.b);
195 x.b = Box::new(3);
196 drop(x.b);
197 }
198
199 fn move_after_field_assign_after_fu_move() {
200 let mut x = A { a: 1, b: Box::new(2) };
201 let _y = A { a: 3, .. x };
202 x.b = Box::new(3);
203 drop(x.b);
204 }
205
206 fn copy_after_assign_after_uninit() {
207 let mut x: A;
208 x = A { a: 1, b: Box::new(2) };
209 drop(x.a);
210 }
211
212 fn borrow_after_assign_after_uninit() {
213 let mut x: A;
214 x = A { a: 1, b: Box::new(2) };
215 let p = &x.a;
216 drop(*p);
217 }
218
219 fn move_after_assign_after_uninit() {
220 let mut x: A;
221 x = A { a: 1, b: Box::new(2) };
222 drop(x.b);
223 }
224
225 fn main() {
226 move_after_copy();
227 move_after_fu_copy();
228 fu_move_after_copy();
229 fu_move_after_fu_copy();
230 copy_after_move();
231 copy_after_fu_move();
232 fu_copy_after_move();
233 fu_copy_after_fu_move();
234
235 borrow_after_move();
236 borrow_after_fu_move();
237 move_after_borrow();
238 fu_move_after_borrow();
239 mut_borrow_after_mut_borrow();
240
241 move_after_move();
242 move_after_fu_move();
243 fu_move_after_move();
244 fu_move_after_fu_move();
245
246 copy_after_assign_after_move();
247 copy_after_assign_after_fu_move();
248 copy_after_field_assign_after_move();
249 copy_after_field_assign_after_fu_move();
250
251 borrow_after_assign_after_move();
252 borrow_after_assign_after_fu_move();
253 borrow_after_field_assign_after_move();
254 borrow_after_field_assign_after_fu_move();
255
256 move_after_assign_after_move();
257 move_after_assign_after_fu_move();
258 move_after_field_assign_after_move();
259 move_after_field_assign_after_fu_move();
260
261 copy_after_assign_after_uninit();
262 borrow_after_assign_after_uninit();
263 move_after_assign_after_uninit();
264 }