-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-codegenArea: Code generationArea: Code generationA-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
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.
Metadata
Metadata
Assignees
Labels
A-codegenArea: Code generationArea: Code generationA-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.