rust/tests/ui/borrowck/borrowck-no-cycle-in-exchange-heap.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
335 B
Rust
Raw Normal View History

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!
2013-03-15 14:24:24 -05:00
match *x {
Cycle::Node(ref mut y) => {
2013-03-15 14:24:24 -05:00
y.a = x; //~ ERROR cannot move out of
}
Cycle::Empty => {}
};
}