]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/unit-like-struct-drop-run.rs
Imported Upstream version 1.8.0+dfsg1
[rustc.git] / src / test / run-pass / unit-like-struct-drop-run.rs
CommitLineData
223e47cc
LB
1// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
7453a54e
SL
11// ignore-emscripten no threads support
12
970d7e83 13// Make sure the destructor is run for unit-like structs.
970d7e83 14
c34b1796
AL
15
16#![feature(alloc)]
17
85aaf69f 18use std::thread;
970d7e83
LB
19
20struct Foo;
21
22impl Drop for Foo {
1a4d82fc
JJ
23 fn drop(&mut self) {
24 panic!("This panic should happen.");
970d7e83
LB
25 }
26}
223e47cc 27
1a4d82fc 28pub fn main() {
85aaf69f 29 let x = thread::spawn(move|| {
970d7e83 30 let _b = Foo;
1a4d82fc
JJ
31 }).join();
32
c34b1796 33 let s = x.err().unwrap().downcast::<&'static str>().unwrap();
85aaf69f 34 assert_eq!(&**s, "This panic should happen.");
223e47cc 35}