summaryrefslogtreecommitdiffstats
path: root/src/test/run-pass-valgrind/dst-dtor-2.rs
blob: 991fe00950bba873593c10832201d10a8a95cccd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
static mut DROP_RAN: isize = 0;

struct Foo;
impl Drop for Foo {
    fn drop(&mut self) {
        unsafe { DROP_RAN += 1; }
    }
}

struct Fat<T: ?Sized> {
    f: T
}

pub fn main() {
    {
        let _x: Box<Fat<[Foo]>> = Box::<Fat<[Foo; 3]>>::new(Fat { f: [Foo, Foo, Foo] });
    }
    unsafe {
        assert_eq!(DROP_RAN, 3);
    }
}