summary refs log tree commit diff
path: root/src/test/compile-fail/borrowck-imm-ref-to-mut-rec-field-issue-3162-b.rs
blob: 3c0a53130b1d61e48a38bd36158ac085098c78b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
fn each<T>(x: &[T], op: fn(elem: &T) -> bool) {
    uint::range(0, x.len(), |i| op(&x[i]));
}

fn main() {
    let x = [{mut a: 0}];
    for each(x) |y| {
        let z = &y.a; //~ ERROR illegal borrow unless pure
        x[0].a = 10; //~ NOTE impure due to assigning to mutable field
        log(error, z);
    }
}