rust/tests/run-pass/zst_variant_drop.rs
2017-02-24 11:04:13 +01:00

24 lines
349 B
Rust

struct Foo;
impl Drop for Foo {
fn drop(&mut self) {
unsafe {
FOO = true;
}
}
}
static mut FOO: bool = false;
enum Bar {
A(Box<i32>),
B(Foo),
}
fn main() {
assert!(unsafe { !FOO });
drop(Bar::A(Box::new(42)));
assert!(unsafe { !FOO });
drop(Bar::B(Foo));
assert!(unsafe { FOO });
}