about summary refs log tree commit diff
path: root/tests/ui/structs-enums/unit-like-struct-drop-run.rs
blob: 5e3fc5931bdc526daaafb10e14415437325528ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//@ run-pass
//@ needs-unwind
//@ needs-threads
//@ ignore-backends: gcc

// Make sure the destructor is run for unit-like structs.

use std::thread;

struct Foo;

impl Drop for Foo {
    fn drop(&mut self) {
        panic!("This panic should happen.");
    }
}

pub fn main() {
    let x = thread::spawn(move|| {
        let _b = Foo;
    }).join();

    let s = x.unwrap_err().downcast::<&'static str>().unwrap();
    assert_eq!(&**s, "This panic should happen.");
}