]> git.proxmox.com Git - rustc.git/blame - src/test/ui/mir/mir_dynamic_drops_1.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / mir / mir_dynamic_drops_1.rs
CommitLineData
f9f354fc 1// run-fail
54a0048b
SL
2// error-pattern:drop 1
3// error-pattern:drop 2
f9f354fc 4// ignore-emscripten no processes
54a0048b
SL
5
6/// Structure which will not allow to be dropped twice.
7struct Droppable<'a>(&'a mut bool, u32);
8impl<'a> Drop for Droppable<'a> {
9 fn drop(&mut self) {
10 if *self.0 {
abe05a73 11 eprintln!("{} dropped twice", self.1);
54a0048b
SL
12 ::std::process::exit(1);
13 }
abe05a73 14 eprintln!("drop {}", self.1);
54a0048b
SL
15 *self.0 = true;
16 }
17}
18
3157f602 19fn mir() {
54a0048b
SL
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
28fn main() {
29 mir();
30 panic!();
31}