]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/pass/drop_on_zst_array_elements.rs
Auto merge of #104915 - weihanglo:update-cargo, r=ehuss
[rust.git] / src / tools / miri / tests / pass / drop_on_zst_array_elements.rs
1 struct Bar;
2
3 static mut DROP_COUNT: usize = 0;
4
5 impl Drop for Bar {
6     fn drop(&mut self) {
7         unsafe {
8             DROP_COUNT += 1;
9         }
10     }
11 }
12
13 fn main() {
14     let b = [Bar, Bar, Bar, Bar];
15     assert_eq!(unsafe { DROP_COUNT }, 0);
16     drop(b);
17     assert_eq!(unsafe { DROP_COUNT }, 4);
18
19     // check empty case
20     let b: [Bar; 0] = [];
21     drop(b);
22     assert_eq!(unsafe { DROP_COUNT }, 4);
23 }