]> git.proxmox.com Git - rustc.git/blob - src/test/ui/nll/closure-use-spans.rs
New upstream version 1.32.0~beta.2+dfsg1
[rustc.git] / src / test / ui / nll / closure-use-spans.rs
1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // check that liveness due to a closure capture gives a special note
12
13 #![feature(nll)]
14
15 fn use_as_borrow_capture(mut x: i32) {
16 let y = &x;
17 x = 0; //~ ERROR
18 || *y;
19 }
20
21 fn use_as_borrow_mut_capture(mut x: i32) {
22 let y = &mut x;
23 x = 0; //~ ERROR
24 || *y = 1;
25 }
26
27 fn use_as_move_capture(mut x: i32) {
28 let y = &x;
29 x = 0; //~ ERROR
30 move || *y;
31 }
32
33 fn main() {}