- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsI-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
I believe the issue is simply that destructors are run in regardless order of borrows. Instead, the destructors with borrows should run first.
This code prints, rust: ~"bye \xffffff91"
class defer {
    x: &str;
    new(x: &str) { self.x = x; }
    drop { #error["%s", self.x]; }
}
fn main() {
    let _x = defer(~"Goodbye world!");
    #error["..."];
}
and this code segfaults:
class defer {
    x: &[&str];
    new(x: &[&str]) { self.x = x; }
    drop { #error["%?", self.x]; }
}
fn main() {
    let _x = defer(~["Goodbye", "world!"]);
}
Metadata
Metadata
Assignees
Labels
A-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsI-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.