]> git.lizzy.rs Git - rust.git/blob - tests/ui/closures/2229_closure_analysis/path-with-array-access.rs
Auto merge of #107843 - bjorn3:sync_cg_clif-2023-02-09, r=bjorn3
[rust.git] / tests / ui / closures / 2229_closure_analysis / path-with-array-access.rs
1 // edition:2021
2
3 #![feature(rustc_attrs)]
4
5 struct Point {
6     x: f32,
7     y: f32,
8 }
9
10 struct Pentagon {
11     points: [Point; 5],
12 }
13
14 fn main() {
15     let p1 = Point { x: 10.0, y: 10.0 };
16     let p2 = Point { x: 7.5, y: 12.5 };
17     let p3 = Point { x: 15.0, y: 15.0 };
18     let p4 = Point { x: 12.5, y: 12.5 };
19     let p5 = Point { x: 20.0, y: 10.0 };
20
21     let pent = Pentagon { points: [p1, p2, p3, p4, p5] };
22
23     let c = #[rustc_capture_analysis]
24     //~^ ERROR: attributes on expressions are experimental
25     //~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
26     || {
27     //~^ ERROR: First Pass analysis includes:
28     //~| ERROR: Min Capture analysis includes:
29         println!("{}", pent.points[5].x);
30         //~^ NOTE: Capturing pent[(0, 0)] -> ImmBorrow
31         //~| NOTE: Min Capture pent[(0, 0)] -> ImmBorrow
32     };
33 }