2018-09-04 05:05:53 -05:00
|
|
|
// run-pass
|
2015-03-22 15:13:15 -05:00
|
|
|
// pretty-expanded FIXME #23616
|
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
struct A { a: isize, b: Box<isize> }
|
2014-06-13 22:48:10 -05:00
|
|
|
|
|
|
|
fn field_copy_after_field_borrow() {
|
2021-08-24 19:39:40 -05:00
|
|
|
let mut x = A { a: 1, b: Box::new(2) };
|
2014-06-13 22:48:10 -05:00
|
|
|
let p = &mut x.b;
|
|
|
|
drop(x.a);
|
|
|
|
**p = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn fu_field_copy_after_field_borrow() {
|
2021-08-24 19:39:40 -05:00
|
|
|
let mut x = A { a: 1, b: Box::new(2) };
|
2014-06-13 22:48:10 -05:00
|
|
|
let p = &mut x.b;
|
2021-08-24 19:39:40 -05:00
|
|
|
let y = A { b: Box::new(3), .. x };
|
2014-06-13 22:48:10 -05:00
|
|
|
drop(y);
|
|
|
|
**p = 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn field_deref_after_field_borrow() {
|
2021-08-24 19:39:40 -05:00
|
|
|
let mut x = A { a: 1, b: Box::new(2) };
|
2014-06-13 22:48:10 -05:00
|
|
|
let p = &mut x.a;
|
|
|
|
drop(*x.b);
|
|
|
|
*p = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn field_move_after_field_borrow() {
|
2021-08-24 19:39:40 -05:00
|
|
|
let mut x = A { a: 1, b: Box::new(2) };
|
2014-06-13 22:48:10 -05:00
|
|
|
let p = &mut x.a;
|
|
|
|
drop(x.b);
|
|
|
|
*p = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn fu_field_move_after_field_borrow() {
|
2021-08-24 19:39:40 -05:00
|
|
|
let mut x = A { a: 1, b: Box::new(2) };
|
2014-06-13 22:48:10 -05:00
|
|
|
let p = &mut x.a;
|
|
|
|
let y = A { a: 3, .. x };
|
|
|
|
drop(y);
|
|
|
|
*p = 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
field_copy_after_field_borrow();
|
|
|
|
fu_field_copy_after_field_borrow();
|
|
|
|
field_deref_after_field_borrow();
|
|
|
|
field_move_after_field_borrow();
|
|
|
|
fu_field_move_after_field_borrow();
|
|
|
|
}
|