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