Skip to content

Double moves out of arrays are allowed #14986

Closed
@zwarich

Description

@zwarich

This program is accepted, but it shouldn't be:

fn f(mut a: [Box<int>, ..2]) {
    drop(a[0]);
    a[1] = box 2;
    drop(a[0]);
}

fn main() {
    f([box 0, box 1]);
}

The problem is that array paths do not incorporate the index, and thus do not refer to a unique location, unlike other LoanPaths. Strong updates to kill previous moves are only valid for paths that refer to a unique location.

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