]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-no-cycle-in-exchange-heap.rs
Rollup merge of #107580 - lenko-d:default_value_for_a_lifetime_generic_parameter_prod...
[rust.git] / tests / ui / borrowck / borrowck-no-cycle-in-exchange-heap.rs
1 struct Node_ {
2     a: Box<Cycle>
3 }
4
5 enum Cycle {
6     Node(Node_),
7     Empty,
8 }
9
10 fn main() {
11     let mut x: Box<_> = Box::new(Cycle::Node(Node_ {a: Box::new(Cycle::Empty)}));
12
13     // Create a cycle!
14     match *x {
15       Cycle::Node(ref mut y) => {
16         y.a = x; //~ ERROR cannot move out of
17       }
18       Cycle::Empty => {}
19     };
20 }