rust/tests/run-pass-valgrind/dst-dtor-2.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
340 B
Rust
Raw Normal View History

static mut DROP_RAN: isize = 0;
2014-08-06 09:59:40 +00:00
struct Foo;
impl Drop for Foo {
fn drop(&mut self) {
unsafe { DROP_RAN += 1; }
}
}
2015-01-05 21:16:49 +00:00
struct Fat<T: ?Sized> {
2014-08-06 09:59:40 +00:00
f: T
}
pub fn main() {
{
let _x: Box<Fat<[Foo]>> = Box::<Fat<[Foo; 3]>>::new(Fat { f: [Foo, Foo, Foo] });
2014-08-06 09:59:40 +00:00
}
unsafe {
assert_eq!(DROP_RAN, 3);
2014-08-06 09:59:40 +00:00
}
}