Closed
Description
rust-lang/rust#39230 changed some things around with boxed, especially that there is a "Drop
impl" now: https://github.com/rust-lang/rust/blame/master/src/liballoc/boxed.rs#L297 (it's empty, doesn't drop its contents)
We should just wait for rustc to fix it.
repro:
#![feature(box_syntax)]
struct DroppableStruct;
static mut DROPPED: bool = false;
impl Drop for DroppableStruct {
fn drop(&mut self) {
unsafe { DROPPED = true; }
}
}
trait MyTrait { fn dummy(&self) { } }
impl MyTrait for Box<DroppableStruct> {}
struct Whatever { w: Box<MyTrait+'static> }
impl Whatever {
fn new(w: Box<MyTrait+'static>) -> Whatever {
Whatever { w: w }
}
}
fn main() {
{
let f: Box<_> = box DroppableStruct;
let _a = Whatever::new(box f as Box<MyTrait>);
}
assert!(unsafe { DROPPED });
}