4 static mut CHECK: usize = 0;
6 struct DropChecker(usize);
8 impl Drop for DropChecker {
11 if CHECK != self.0 - 1 {
12 panic!("Found {}, should have found {}", CHECK, self.0 - 1);
19 macro_rules! check_drops {
21 unsafe { assert_eq!(CHECK, $l) }
27 impl Drop for DropPanic {
35 let foo = DropChecker(1);
36 let v: [DropChecker; 0] = [foo; 0];
44 let foo = DropChecker(1);
45 let v: [DropChecker; 1] = [foo; 1];
51 const DROP_CHECKER: DropChecker = DropChecker(1);
55 let v: [DropChecker; 0] = [DROP_CHECKER; 0];
63 let v: [DropChecker; 1] = [DROP_CHECKER; 1];
69 fn const_generic_zero<const N: usize>() {
71 let v: [DropChecker; N] = [DROP_CHECKER; N];
77 fn const_generic_one<const N: usize>() {
79 let v: [DropChecker; N] = [DROP_CHECKER; N];
85 // Make sure that things are allowed to promote as expected
89 let foo = DropChecker(1);
90 let v: &'static [DropChecker; 0] = &[foo; 0];
96 // Verify that unwinding in the drop causes the right things to drop in the right order
99 std::panic::catch_unwind(|| {
100 let panic = DropPanic;
101 let _local = DropChecker(2);
102 let _v = (DropChecker(1), [panic; 0]);
103 std::process::abort();
114 const_generic_zero::<0>();
115 const_generic_one::<1>();