summary refs log tree commit diff
path: root/src/test/run-pass/vec-slice-drop.rs
blob: 2c5225fa0f9a279d8b8a64b39570c588d6c9e7c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Make sure that destructors get run on slice literals
class foo {
    let x: @mut int;
    new(x: @mut int) { self.x = x; }
    drop { *self.x += 1; }
}

fn main() {
    let x = @mut 0;
    {
        let l = &[foo(x)];
        assert *l[0].x == 0;
    }
    assert *x == 1;
}