]> git.lizzy.rs Git - rust.git/blob - src/test/ui/closures/2229_closure_analysis/capture-disjoint-field-struct.rs
Log closure as well
[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 //~| NOTE: `#[warn(incomplete_features)]` on by default
6 //~| NOTE: see issue #53488 <https://github.com/rust-lang/rust/issues/53488>
7 #![feature(rustc_attrs)]
8
9 struct Point {
10     x: i32,
11     y: i32,
12 }
13
14 fn main() {
15     let mut p = Point { x: 10, y: 10 };
16
17     let c = #[rustc_capture_analysis]
18     //~^ ERROR: attributes on expressions are experimental
19     //~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
20     || {
21     //~^ First Pass analysis includes:
22     //~| Min Capture analysis includes:
23         println!("{}", p.x);
24         //~^ NOTE: Capturing p[(0, 0)] -> ImmBorrow
25         //~| NOTE: Min Capture p[(0, 0)] -> ImmBorrow
26     };
27
28     // `c` should only capture `p.x`, therefore mutating `p.y` is allowed.
29     let py = &mut p.y;
30
31     c();
32     *py = 20;
33 }