rust/src/test/run-pass/unit-like-struct-drop-run.rs
Alex Crichton f19e763e08 std: Stabilize the rest of Any/BoxAny
This commit stabilizes the following APIs:

* `TypeId::of` - now that it has an `Any` bound it's ready to be stable.
* `Box<Any>::downcast` - now that an inherent impl on `Box<Any>` as well as
  `Box<Any+Send>` is allowed the `BoxAny` trait is removed in favor of these
  inherent methods.

This is a breaking change due to the removal of the `BoxAny` trait, but
consumers can simply remove imports to fix crates.

[breaking-change]
2015-03-30 16:44:11 -07:00

35 lines
917 B
Rust

// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Make sure the destructor is run for unit-like structs.
// pretty-expanded FIXME #23616
#![feature(alloc)]
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.err().unwrap().downcast::<&'static str>().unwrap();
assert_eq!(&**s, "This panic should happen.");
}