Closed
Description
struct S<T> { field: T }
#[unsafe_destructor]
impl<T> Drop for S<T> {
fn drop(&self) {
println(fmt!("drop %?", self));
}
}
fn main() {
let i = 7496034;
let _s1 = S { field: (&i, 4) };
let _s2 = S { field: "foo" };
}
prints
drop &{field: "foo"}
drop &{field: "bar"}
I suppose the clue is in the name of that attribute, but I figured this case is worth noting--I expected somewhat more subtle unsafety.
It does the right thing if the destructor refers to the field specifically.