1 // Test that `Box<T>` is treated specially by borrow checking. This is the case
2 // because NLL reverted the deicision in rust-lang/rfcs#130.
26 fn copy_after_move() {
27 let a
: Box
<_
> = Box
::new(A { x: Box::new(0), y: 1 }
);
32 fn move_after_move() {
33 let a
: Box
<_
> = Box
::new(B { x: Box::new(0), y: Box::new(1) }
);
38 fn borrow_after_move() {
39 let a
: Box
<_
> = Box
::new(A { x: Box::new(0), y: 1 }
);
44 fn move_after_borrow() {
45 let a
: Box
<_
> = Box
::new(B { x: Box::new(0), y: Box::new(1) }
);
50 fn copy_after_mut_borrow() {
51 let mut a
: Box
<_
> = Box
::new(A { x: Box::new(0), y: 1 }
);
56 fn move_after_mut_borrow() {
57 let mut a
: Box
<_
> = Box
::new(B { x: Box::new(0), y: Box::new(1) }
);
62 fn borrow_after_mut_borrow() {
63 let mut a
: Box
<_
> = Box
::new(A { x: Box::new(0), y: 1 }
);
68 fn mut_borrow_after_borrow() {
69 let mut a
: Box
<_
> = Box
::new(A { x: Box::new(0), y: 1 }
);
74 fn copy_after_move_nested() {
75 let a
: Box
<_
> = Box
::new(C { x: Box::new(A { x: Box::new(0), y: 1 }
), y
: 2 });
80 fn move_after_move_nested() {
81 let a
: Box
<_
> = Box
::new(D { x: Box::new(A { x: Box::new(0), y: 1 }
), y
: Box
::new(2) });
86 fn borrow_after_move_nested() {
87 let a
: Box
<_
> = Box
::new(C { x: Box::new(A { x: Box::new(0), y: 1 }
), y
: 2 });
92 fn move_after_borrow_nested() {
93 let a
: Box
<_
> = Box
::new(D { x: Box::new(A { x: Box::new(0), y: 1 }
), y
: Box
::new(2) });
98 fn copy_after_mut_borrow_nested() {
99 let mut a
: Box
<_
> = Box
::new(C { x: Box::new(A { x: Box::new(0), y: 1 }
), y
: 2 });
104 fn move_after_mut_borrow_nested() {
105 let mut a
: Box
<_
> = Box
::new(D { x: Box::new(A { x: Box::new(0), y: 1 }
), y
: Box
::new(2) });
110 fn borrow_after_mut_borrow_nested() {
111 let mut a
: Box
<_
> = Box
::new(C { x: Box::new(A { x: Box::new(0), y: 1 }
), y
: 2 });
116 fn mut_borrow_after_borrow_nested() {
117 let mut a
: Box
<_
> = Box
::new(C { x: Box::new(A { x: Box::new(0), y: 1 }
), y
: 2 });
130 copy_after_mut_borrow();
131 move_after_mut_borrow();
132 borrow_after_mut_borrow();
133 mut_borrow_after_borrow();
135 copy_after_move_nested();
136 move_after_move_nested();
137 borrow_after_move_nested();
139 move_after_borrow_nested();
141 copy_after_mut_borrow_nested();
142 move_after_mut_borrow_nested();
143 borrow_after_mut_borrow_nested();
144 mut_borrow_after_borrow_nested();
147 fn use_mut
<T
>(_
: &mut T
) { }
148 fn use_imm
<T
>(_
: &T
) { }