summaryrefslogtreecommitdiffstats
path: root/tests/ui/nll/closures-in-loops.rs
blob: 491c186ecb5a018b54fffd2704f93ead8c5109b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Test messages where a closure capture conflicts with itself because it's in
// a loop.

fn repreated_move(x: String) {
    for i in 0..10 {
        || x; //~ ERROR
    }
}

fn repreated_mut_borrow(mut x: String) {
    let mut v = Vec::new();
    for i in 0..10 {
        v.push(|| x = String::new()); //~ ERROR
    }
}

fn repreated_unique_borrow(x: &mut String) {
    let mut v = Vec::new();
    for i in 0..10 {
        v.push(|| *x = String::new()); //~ ERROR
    }
}

fn main() {}