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