]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/closure-access-spans.rs
Rollup merge of #57107 - mjbshaw:thread_local_test, r=nikomatsakis
[rust.git] / src / test / ui / nll / closure-access-spans.rs
1 // check that accesses due to a closure capture give a special note
2
3 #![feature(nll)]
4
5 fn closure_imm_capture_conflict(mut x: i32) {
6     let r = &mut x;
7     || x; //~ ERROR
8     r.use_mut();
9 }
10
11 fn closure_mut_capture_conflict(mut x: i32) {
12     let r = &mut x;
13     || x = 2; //~ ERROR
14     r.use_mut();
15 }
16
17 fn closure_unique_capture_conflict(mut x: &mut i32) {
18     let r = &mut x;
19     || *x = 2; //~ ERROR
20     r.use_mut();
21 }
22
23 fn closure_copy_capture_conflict(mut x: i32) {
24     let r = &mut x;
25     move || x; //~ ERROR
26     r.use_ref();
27 }
28
29 fn closure_move_capture_conflict(mut x: String) {
30     let r = &x;
31     || x; //~ ERROR
32     r.use_ref();
33 }
34
35 fn closure_imm_capture_moved(mut x: String) {
36     let r = x;
37     || x.len(); //~ ERROR
38 }
39
40 fn closure_mut_capture_moved(mut x: String) {
41     let r = x;
42     || x = String::new(); //~ ERROR
43 }
44
45 fn closure_unique_capture_moved(x: &mut String) {
46     let r = x;
47     || *x = String::new(); //~ ERROR
48 }
49
50 fn closure_move_capture_moved(x: &mut String) {
51     let r = x;
52     || x; //~ ERROR
53 }
54
55 fn main() {}
56
57 trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { }  }
58 impl<T> Fake for T { }