]> git.lizzy.rs Git - rust.git/blob - tests/ui/panics/panic-in-dtor-drops-fields.rs
Rollup merge of #105526 - Xiretza:iter-from-generator-derive, r=scottmcm
[rust.git] / tests / ui / panics / panic-in-dtor-drops-fields.rs
1 // run-pass
2 // needs-unwind
3 #![allow(dead_code)]
4 #![allow(non_upper_case_globals)]
5
6 // ignore-emscripten no threads support
7
8 use std::thread;
9
10 static mut dropped: bool = false;
11
12 struct A {
13     b: B,
14 }
15
16 struct B {
17     foo: isize,
18 }
19
20 impl Drop for A {
21     fn drop(&mut self) {
22         panic!()
23     }
24 }
25
26 impl Drop for B {
27     fn drop(&mut self) {
28         unsafe { dropped = true; }
29     }
30 }
31
32 pub fn main() {
33     let ret = thread::spawn(move|| {
34         let _a = A { b: B { foo: 3 } };
35     }).join();
36     assert!(ret.is_err());
37     unsafe { assert!(dropped); }
38 }