Skip to content

Regioned destructors don't run in the right order #3164

Closed
@bblum

Description

@bblum

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

No one assigned

    Labels

    A-destructorsArea: Destructors (`Drop`, …)A-lifetimesArea: Lifetimes / regionsI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions