Skip to content

Better error message for "argument 1 may alias with argument 0, which is not immutably rooted" #1822

Closed
@hildjj

Description

@hildjj

Given this program:

use std;

fn main() {
    let a = {mutable foo: [mutable 1u]};
    vec::iteri(a.foo) {|i, v|
        #error("%u = %u", i, v);
    }
}

The error produced is: "m.rs:5:19: 7:2 error: argument 1 may alias with argument 0, which is not immutably rooted", which is more than a little jargon-y. If this is really an error, then it should be easier to understand what the problem is. Note that this program compiles cleanly:

use std;

fn main() {
    let a = {mutable foo: [mutable 1u]};
    let f = a.foo; // add a temp
    vec::iteri(f) {|i, v|
        #error("%u = %u", i, v);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions