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

fn foo(x: @mut int) -> foo {
    foo {
        x: x
    }
}

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