1 // error-pattern:unwind happens
2 // error-pattern:drop 3
3 // error-pattern:drop 2
4 // error-pattern:drop 1
5 // ignore-cloudabi no std::process
7 /// Structure which will not allow to be dropped twice.
8 struct Droppable<'a>(&'a mut bool, u32);
9 impl<'a> Drop for Droppable<'a> {
12 eprintln!("{} dropped twice", self.1);
13 ::std::process::exit(1);
15 eprintln!("drop {}", self.1);
20 fn may_panic<'a>() -> Droppable<'a> {
21 panic!("unwind happens");
24 fn mir<'a>(d: Droppable<'a>) {
25 let (mut a, mut b) = (false, false);
26 let y = Droppable(&mut a, 2);
27 let x = [Droppable(&mut b, 1), y, d, may_panic()];
32 mir(Droppable(&mut c, 3));