]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/pass/drop_on_fat_ptr_array_elements.rs
Auto merge of #101833 - jyn514:cross-compile-compiler-builtins, r=Mark-Simulacrum
[rust.git] / src / tools / miri / tests / pass / drop_on_fat_ptr_array_elements.rs
1 trait Foo {}
2
3 struct Bar;
4
5 impl Foo for Bar {}
6
7 static mut DROP_COUNT: usize = 0;
8
9 impl Drop for Bar {
10     fn drop(&mut self) {
11         unsafe {
12             DROP_COUNT += 1;
13         }
14     }
15 }
16
17 fn main() {
18     let b: [Box<dyn Foo>; 4] = [Box::new(Bar), Box::new(Bar), Box::new(Bar), Box::new(Bar)];
19     assert_eq!(unsafe { DROP_COUNT }, 0);
20     drop(b);
21     assert_eq!(unsafe { DROP_COUNT }, 4);
22 }