2018-08-30 14:18:55 +02:00
|
|
|
//@ run-pass
|
2021-12-03 15:32:51 +00:00
|
|
|
//@ needs-unwind
|
2018-09-25 23:51:35 +02:00
|
|
|
#![allow(dead_code)]
|
2018-08-31 15:02:01 +02:00
|
|
|
#![allow(non_upper_case_globals)]
|
|
|
|
|
|
2025-01-23 17:05:01 +08:00
|
|
|
//@ needs-threads
|
2015-03-22 13:13:15 -07:00
|
|
|
|
2015-02-17 15:24:34 -08:00
|
|
|
use std::thread;
|
2013-10-31 23:31:11 -07:00
|
|
|
|
|
|
|
|
static mut dropped: bool = false;
|
|
|
|
|
|
|
|
|
|
struct A {
|
|
|
|
|
b: B,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct B {
|
2015-03-25 17:06:52 -07:00
|
|
|
foo: isize,
|
2013-10-31 23:31:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Drop for A {
|
|
|
|
|
fn drop(&mut self) {
|
2014-10-09 15:17:22 -04:00
|
|
|
panic!()
|
2013-10-31 23:31:11 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Drop for B {
|
|
|
|
|
fn drop(&mut self) {
|
|
|
|
|
unsafe { dropped = true; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn main() {
|
2015-02-17 15:24:34 -08:00
|
|
|
let ret = thread::spawn(move|| {
|
2013-10-31 23:31:11 -07:00
|
|
|
let _a = A { b: B { foo: 3 } };
|
2015-01-01 23:53:35 -08:00
|
|
|
}).join();
|
2013-10-31 23:31:11 -07:00
|
|
|
assert!(ret.is_err());
|
|
|
|
|
unsafe { assert!(dropped); }
|
|
|
|
|
}
|