Skip to content

Crash on the use of moved value in the closure #6653

Closed
@lifthrasiir

Description

@lifthrasiir

The following code segfaults in both 0.6 and the current incoming:

struct A { t: bool }
fn main() {
    let mut a = ~A { t: false };
    let f = || { a.t = true; };
    let mut x = a;
    f();
    x.t = false; // not strictly required but ignores an warning
}

The cause is that a was moved to x and f (created before the movement) was unable to deduce that a has been moved. Ideally such code should not compile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-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