summaryrefslogtreecommitdiffstats
path: root/src/test/ui/drop/nondrop-cycle.rs
blob: 29070f917e43256beab25c60ebdd8a88539ddc69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// run-pass
// pretty-expanded FIXME #23616

use std::cell::Cell;

struct C<'a> {
    p: Cell<Option<&'a C<'a>>>,
}

impl<'a> C<'a> {
    fn new() -> C<'a> { C { p: Cell::new(None) } }
}

fn f1() {
    let (c1, c2) = (C::new(), C::new());
    c1.p.set(Some(&c2));
    c2.p.set(Some(&c1));
}

fn f2() {
    let (c1, c2);
    c1 = C::new();
    c2 = C::new();
    c1.p.set(Some(&c2));
    c2.p.set(Some(&c1));
}

fn main() {
    f1();
    f2();
}