]> git.lizzy.rs Git - rust.git/blob - src/test/run-fail/mir_dynamic_drops_2.rs
Use better bound names in `-Zverbose` mode
[rust.git] / src / test / run-fail / mir_dynamic_drops_2.rs
1 // error-pattern:drop 1
2 // ignore-cloudabi no std::process
3
4 /// Structure which will not allow to be dropped twice.
5 struct Droppable<'a>(&'a mut bool, u32);
6 impl<'a> Drop for Droppable<'a> {
7     fn drop(&mut self) {
8         if *self.0 {
9             eprintln!("{} dropped twice", self.1);
10             ::std::process::exit(1);
11         }
12         eprintln!("drop {}", self.1);
13         *self.0 = true;
14     }
15 }
16
17 fn mir<'a>(d: Droppable<'a>) {
18     loop {
19         let x = d;
20         break;
21     }
22 }
23
24 fn main() {
25     let mut xv = false;
26     mir(Droppable(&mut xv, 1));
27     panic!();
28 }