mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 07:44:10 +00:00
27 lines
417 B
Rust
27 lines
417 B
Rust
//@ run-pass
|
|
|
|
static mut DROPPED: [bool; 2] = [false, false];
|
|
|
|
struct A(usize);
|
|
struct Foo { _a: A, _b: isize }
|
|
|
|
impl Drop for A {
|
|
fn drop(&mut self) {
|
|
let A(i) = *self;
|
|
unsafe { DROPPED[i] = true; }
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
{
|
|
Foo {
|
|
_a: A(0),
|
|
..Foo { _a: A(1), _b: 2 }
|
|
};
|
|
}
|
|
unsafe {
|
|
assert!(DROPPED[0]);
|
|
assert!(DROPPED[1]);
|
|
}
|
|
}
|