Skip to content

Shouldn't be able to let-pattern-unwrap structs with dtors #3218

@bblum

Description

@bblum
struct X {
    x: ~str;
    drop {
        error!("destructing wrapper");
        error!("value: %s", self.x);
    }
}

fn foo(+x: X) -> ~str {
    let X { x: y } = x;
    error!("unwrapped it");
    y
}

fn main() {
    let x = X { x: ~"hello" };
    let y = foo(x);
    error!("got inner");
    error!("contents: %s", y);
}

prints:

rust: ~"unwrapped it"
rust: ~"destructing wrapper"
Segmentation fault (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions