Skip to content

Allow moves in closures if closure reinitializes moved variables. #2757

@eholk

Description

@eholk

Currently, we can't write programs like this:

fn main() {
    let mut x = ~1;

    for int::range(0, 10) {|i|
        let z <- x;
        x = ~(*z * i);
    }
}

At first glance this looks like it should be safe, since any time we move out of x, we also put something back in it. If this really is safe, we should allow it. If this isn't safe, could someone post an example that breaks?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions