summary refs log tree commit diff
path: root/src/test/compile-fail/regions-escape-loop-via-variable.rs
blob: e63a0717503291236acb510b1aac2ff82ce7988f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
fn main() {
    let x = 3;

    // Here, the variable `p` gets inferred to a type with a lifetime
    // of the loop body.  The regionck then determines that this type
    // is invalid.
    let mut p = &x;

    loop {
        let x = 1 + *p;
        p = &x; //~ ERROR illegal borrow
    }
}