]>
Commit | Line | Data |
---|---|---|
83c7162d | 1 | // Copyright 2018 The Rust Project Developers. See the COPYRIGHT |
223e47cc LB |
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 | ||
b7449926 XL |
11 | // check that liveness due to a closure capture gives a special note |
12 | ||
83c7162d | 13 | #![feature(nll)] |
041b39d2 | 14 | |
b7449926 XL |
15 | fn use_as_borrow_capture(mut x: i32) { |
16 | let y = &x; | |
17 | x = 0; //~ ERROR | |
18 | || *y; | |
476ff2be | 19 | } |
041b39d2 | 20 | |
b7449926 XL |
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) { | |
83c7162d | 28 | let y = &x; |
b7449926 XL |
29 | x = 0; //~ ERROR |
30 | move || *y; | |
041b39d2 | 31 | } |
b7449926 XL |
32 | |
33 | fn main() {} |