2014-06-27 15:54:18 -05: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 09:29:52 -06:00
|
|
|
trait Trait { fn dummy(&self) { } }
|
2014-06-27 15:54:18 -05:00
|
|
|
impl Trait for Foo {}
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
{
|
2022-07-06 21:36:10 -05:00
|
|
|
let _x: &Trait = &*(Box::new(Foo) as Box<Trait>);
|
2014-06-27 15:54:18 -05:00
|
|
|
}
|
|
|
|
unsafe {
|
|
|
|
assert!(DROP_RAN);
|
|
|
|
}
|
|
|
|
}
|