]> git.lizzy.rs Git - rust.git/blob - src/test/ui/array-slice-vec/arr_cycle.rs
Move panic safety traits tests
[rust.git] / src / test / ui / array-slice-vec / arr_cycle.rs
1 // run-pass
2
3 use std::cell::Cell;
4
5 #[derive(Debug)]
6 struct B<'a> {
7     a: [Cell<Option<&'a B<'a>>>; 2]
8 }
9
10 impl<'a> B<'a> {
11     fn new() -> B<'a> {
12         B { a: [Cell::new(None), Cell::new(None)] }
13     }
14 }
15
16 fn f() {
17     let (b1, b2, b3);
18     b1 = B::new();
19     b2 = B::new();
20     b3 = B::new();
21     b1.a[0].set(Some(&b2));
22     b1.a[1].set(Some(&b3));
23     b2.a[0].set(Some(&b2));
24     b2.a[1].set(Some(&b3));
25     b3.a[0].set(Some(&b1));
26     b3.a[1].set(Some(&b2));
27 }
28
29 fn main() {
30     f();
31 }