2012-12-10 19:32:48 -06:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2013-02-21 17:19:40 -06:00
|
|
|
struct node_ {
|
2013-02-22 18:08:16 -06:00
|
|
|
a: ~cycle
|
2013-02-21 17:19:40 -06:00
|
|
|
}
|
|
|
|
|
2012-06-08 09:46:14 -05:00
|
|
|
enum cycle {
|
2013-02-21 17:19:40 -06:00
|
|
|
node(node_),
|
2012-06-08 09:46:14 -05:00
|
|
|
empty
|
|
|
|
}
|
|
|
|
fn main() {
|
2013-02-22 18:08:16 -06:00
|
|
|
let mut x = ~node(node_ {a: ~empty});
|
2012-06-08 09:46:14 -05:00
|
|
|
// Create a cycle!
|
2013-02-22 18:08:16 -06:00
|
|
|
match *x { //~ NOTE loan of mutable local variable granted here
|
|
|
|
node(ref mut y) => {
|
|
|
|
y.a = x; //~ ERROR moving out of mutable local variable prohibited due to outstanding loan
|
2012-06-08 09:46:14 -05:00
|
|
|
}
|
2012-08-23 16:44:58 -05:00
|
|
|
empty => {}
|
2012-06-08 09:46:14 -05:00
|
|
|
};
|
2012-08-07 08:04:36 -05:00
|
|
|
}
|