summaryrefslogtreecommitdiffstats
path: root/src/test/ui/structs-enums/unit-like-struct-drop-run.rs
blob: 1e9c269a4d3756148ccf14935ef060ed55b7ac6c (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
// run-pass
// needs-unwind
// ignore-emscripten no threads support

// 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.");
}