]> git.proxmox.com Git - rustc.git/blame - src/test/ui/borrowck/borrowck-no-cycle-in-exchange-heap.rs
New upstream version 1.30.0~beta.7+dfsg1
[rustc.git] / src / test / ui / borrowck / borrowck-no-cycle-in-exchange-heap.rs
CommitLineData
223e47cc
LB
1// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
1a4d82fc
JJ
11#![feature(box_syntax)]
12
223e47cc 13struct node_ {
1a4d82fc 14 a: Box<cycle>
223e47cc
LB
15}
16
17enum cycle {
18 node(node_),
19 empty
20}
21fn main() {
c34b1796 22 let mut x: Box<_> = box cycle::node(node_ {a: box cycle::empty});
223e47cc 23 // Create a cycle!
970d7e83 24 match *x {
1a4d82fc 25 cycle::node(ref mut y) => {
970d7e83 26 y.a = x; //~ ERROR cannot move out of
223e47cc 27 }
1a4d82fc 28 cycle::empty => {}
223e47cc
LB
29 };
30}