summaryrefslogtreecommitdiffstats
path: root/tests/ui/borrowck/borrowck-no-cycle-in-exchange-heap.rs
blob: f035049d82d8db4fb2bbfb664aaf9b47d689b38d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
struct Node_ {
    a: Box<Cycle>
}

enum Cycle {
    Node(Node_),
    Empty,
}

fn main() {
    let mut x: Box<_> = Box::new(Cycle::Node(Node_ {a: Box::new(Cycle::Empty)}));

    // Create a cycle!
    match *x {
      Cycle::Node(ref mut y) => {
        y.a = x; //~ ERROR cannot move out of
      }
      Cycle::Empty => {}
    };
}