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