summaryrefslogtreecommitdiffstats
path: root/tests/ui/nll/closure-use-spans.rs
blob: 6768250dcbc0aa447a9aaa7b686b42c343e80c79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// check that liveness due to a closure capture gives a special note

fn use_as_borrow_capture(mut x: i32) {
    let y = &x;
    x = 0; //~ ERROR
    || *y;
}

fn use_as_borrow_mut_capture(mut x: i32) {
    let y = &mut x;
    x = 0; //~ ERROR
    || *y = 1;
}

fn use_as_move_capture(mut x: i32) {
    let y = &x;
    x = 0; //~ ERROR
    move || *y;
}

fn main() {}