]> git.lizzy.rs Git - rust.git/blob - src/test/ui/closures/2229_closure_analysis/wild_patterns.rs
Address review comments 2
[rust.git] / src / test / ui / closures / 2229_closure_analysis / wild_patterns.rs
1 #![feature(capture_disjoint_fields)]
2 //~^ WARNING the feature `capture_disjoint_fields` is incomplete
3 #![feature(rustc_attrs)]
4
5 // Test to ensure that we can handle cases where
6 // let statements create no bindings are intialized
7 // using a Place expression
8 //
9 // Note: Currently when feature `capture_disjoint_fields` is enabled
10 // we can't handle such cases. So the test so the test
11
12 struct Point {
13     x: i32,
14     y: i32,
15 }
16
17 fn wild_struct() {
18     let p = Point { x: 10, y: 20 };
19
20     let c = #[rustc_capture_analysis]
21     //~^ ERROR: attributes on expressions are experimental
22     || {
23         // FIXME(arora-aman): Change `_x` to `_`
24         let Point { x: _x, y: _ } = p;
25         //~^ ERROR: Capturing p[(0, 0)] -> ImmBorrow
26         //~| ERROR: Min Capture p[(0, 0)] -> ImmBorrow
27     };
28
29     c();
30 }
31
32 fn wild_tuple() {
33     let t = (String::new(), 10);
34
35     let c = #[rustc_capture_analysis]
36     //~^ ERROR: attributes on expressions are experimental
37     || {
38         // FIXME(arora-aman): Change `_x` to `_`
39         let (_x, _) = t;
40         //~^ ERROR: Capturing t[(0, 0)] -> ByValue
41         //~| ERROR: Min Capture t[(0, 0)] -> ByValue
42     };
43
44     c();
45 }
46
47 fn wild_arr() {
48     let arr = [String::new(), String::new()];
49
50     let c = #[rustc_capture_analysis]
51     //~^ ERROR: attributes on expressions are experimental
52     || {
53         // FIXME(arora-aman): Change `_x` to `_`
54         let [_x, _] = arr;
55         //~^ ERROR: Capturing arr[Index] -> ByValue
56         //~| ERROR: Min Capture arr[] -> ByValue
57     };
58
59     c();
60 }
61
62 fn main() {}