2020-04-16 01:50:32 -05:00
|
|
|
// run-fail
|
2016-01-31 07:07:18 -06:00
|
|
|
// error-pattern:drop 1
|
2020-05-07 10:39:02 -05:00
|
|
|
// ignore-emscripten no processes
|
2016-01-31 07:07:18 -06:00
|
|
|
|
|
|
|
/// Structure which will not allow to be dropped twice.
|
2016-02-24 12:36:20 -06:00
|
|
|
struct Droppable<'a>(&'a mut bool, u32);
|
|
|
|
impl<'a> Drop for Droppable<'a> {
|
2016-01-31 07:07:18 -06:00
|
|
|
fn drop(&mut self) {
|
2016-02-24 12:36:20 -06:00
|
|
|
if *self.0 {
|
2017-09-24 23:14:56 -05:00
|
|
|
eprintln!("{} dropped twice", self.1);
|
2016-01-31 07:07:18 -06:00
|
|
|
::std::process::exit(1);
|
|
|
|
}
|
2017-09-24 23:14:56 -05:00
|
|
|
eprintln!("drop {}", self.1);
|
2016-02-24 12:36:20 -06:00
|
|
|
*self.0 = true;
|
2016-01-31 07:07:18 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-26 21:39:36 -05:00
|
|
|
fn mir<'a>(d: Droppable<'a>) {
|
2016-01-31 07:07:18 -06:00
|
|
|
loop {
|
|
|
|
let x = d;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2016-02-24 12:36:20 -06:00
|
|
|
let mut xv = false;
|
|
|
|
mir(Droppable(&mut xv, 1));
|
2016-01-31 07:07:18 -06:00
|
|
|
panic!();
|
|
|
|
}
|