rust/src/test/ui/borrowck/borrowck-no-cycle-in-exchange-heap.rs
2018-12-25 21:08:33 -07:00

21 lines
346 B
Rust

#![feature(box_syntax)]
struct Node_ {
a: Box<Cycle>
}
enum Cycle {
Node(Node_),
Empty,
}
fn main() {
let mut x: Box<_> = box Cycle::Node(Node_ {a: box Cycle::Empty});
// Create a cycle!
match *x {
Cycle::Node(ref mut y) => {
y.a = x; //~ ERROR cannot move out of
}
Cycle::Empty => {}
};
}