2014-06-27 20:54:18 +00:00
|
|
|
// This would previously leak the Box<Trait> because we wouldn't
|
|
|
|
// schedule cleanups when auto borrowing trait objects.
|
|
|
|
// This program should be valgrind clean.
|
|
|
|
|
|
|
|
static mut DROP_RAN: bool = false;
|
|
|
|
|
|
|
|
struct Foo;
|
|
|
|
impl Drop for Foo {
|
|
|
|
fn drop(&mut self) {
|
|
|
|
unsafe { DROP_RAN = true; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-12 15:29:52 +00:00
|
|
|
trait Trait { fn dummy(&self) { } }
|
2014-06-27 20:54:18 +00:00
|
|
|
impl Trait for Foo {}
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
{
|
2022-07-07 02:36:10 +00:00
|
|
|
let _x: &Trait = &*(Box::new(Foo) as Box<Trait>);
|
2014-06-27 20:54:18 +00:00
|
|
|
}
|
|
|
|
unsafe {
|
|
|
|
assert!(DROP_RAN);
|
|
|
|
}
|
|
|
|
}
|