summary refs log tree commit diff
path: root/src/test/run-pass/while-prelude-drop.rs
blob: a4a685caff6da59e2a1f055ba861ad7cf82606ff (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
32
33
34
35
36
37
38
39

enum t { a, b(~str), }

impl t : cmp::Eq {
    pure fn eq(other: &t) -> bool {
        match self {
            a => {
                match (*other) {
                    a => true,
                    b(_) => false
                }
            }
            b(s0) => {
                match (*other) {
                    a => false,
                    b(s1) => s0 == s1
                }
            }
        }
    }
    pure fn ne(other: &t) -> bool { !self.eq(other) }
}

fn make(i: int) -> t {
    if i > 10 { return a; }
    let mut s = ~"hello";
    // Ensure s is non-const.

    s += ~"there";
    return b(s);
}

fn main() {
    let mut i = 0;


    // The auto slot for the result of make(i) should not leak.
    while make(i) != a { i += 1; }
}