]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-use-mut-borrow-rpass.rs
Auto merge of #75936 - sdroege:chunks-exact-construction-bounds-check, r=nagisa
[rust.git] / src / test / ui / borrowck / borrowck-use-mut-borrow-rpass.rs
1 // run-pass
2 // pretty-expanded FIXME #23616
3
4 #![feature(box_syntax)]
5
6 struct A { a: isize, b: Box<isize> }
7
8 fn field_copy_after_field_borrow() {
9     let mut x = A { a: 1, b: box 2 };
10     let p = &mut x.b;
11     drop(x.a);
12     **p = 3;
13 }
14
15 fn fu_field_copy_after_field_borrow() {
16     let mut x = A { a: 1, b: box 2 };
17     let p = &mut x.b;
18     let y = A { b: box 3, .. x };
19     drop(y);
20     **p = 4;
21 }
22
23 fn field_deref_after_field_borrow() {
24     let mut x = A { a: 1, b: box 2 };
25     let p = &mut x.a;
26     drop(*x.b);
27     *p = 3;
28 }
29
30 fn field_move_after_field_borrow() {
31     let mut x = A { a: 1, b: box 2 };
32     let p = &mut x.a;
33     drop(x.b);
34     *p = 3;
35 }
36
37 fn fu_field_move_after_field_borrow() {
38     let mut x = A { a: 1, b: box 2 };
39     let p = &mut x.a;
40     let y = A { a: 3, .. x };
41     drop(y);
42     *p = 4;
43 }
44
45 fn main() {
46     field_copy_after_field_borrow();
47     fu_field_copy_after_field_borrow();
48     field_deref_after_field_borrow();
49     field_move_after_field_borrow();
50     fu_field_move_after_field_borrow();
51 }