]> git.proxmox.com Git - rustc.git/blob - tests/ui/mir/mir_dynamic_drops_1.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / mir / mir_dynamic_drops_1.rs
1 // run-fail
2 // error-pattern:drop 1
3 // error-pattern:drop 2
4 // ignore-emscripten no processes
5
6 /// Structure which will not allow to be dropped twice.
7 struct Droppable<'a>(&'a mut bool, u32);
8 impl<'a> Drop for Droppable<'a> {
9 fn drop(&mut self) {
10 if *self.0 {
11 eprintln!("{} dropped twice", self.1);
12 ::std::process::exit(1);
13 }
14 eprintln!("drop {}", self.1);
15 *self.0 = true;
16 }
17 }
18
19 fn mir() {
20 let (mut xv, mut yv) = (false, false);
21 let x = Droppable(&mut xv, 1);
22 let y = Droppable(&mut yv, 2);
23 let mut z = x;
24 let k = y;
25 z = k;
26 }
27
28 fn main() {
29 mir();
30 panic!();
31 }