]> git.lizzy.rs Git - rust.git/blob - src/test/ui/closures/2229_closure_analysis/capture-disjoint-field-struct.rs
Reduce verbosity of capture analysis logs
[rust.git] / src / test / ui / closures / 2229_closure_analysis / capture-disjoint-field-struct.rs
1 // FIXME(arora-aman) add run-pass once 2229 is implemented
2
3 #![feature(capture_disjoint_fields)]
4 //~^ WARNING the feature `capture_disjoint_fields` is incomplete
5 #![feature(rustc_attrs)]
6
7 struct Point {
8     x: i32,
9     y: i32,
10 }
11
12 fn main() {
13     let mut p = Point { x: 10, y: 10 };
14
15     let c = #[rustc_capture_analysis]
16     //~^ ERROR: attributes on expressions are experimental
17     || {
18         println!("{}", p.x);
19         //~^ ERROR: Capturing p[(0, 0)] -> ImmBorrow
20         //~^^ ERROR: Min Capture p[(0, 0)] -> ImmBorrow
21     };
22
23     // `c` should only capture `p.x`, therefore mutating `p.y` is allowed.
24     let py = &mut p.y;
25
26     c();
27     *py = 20;
28 }