]> git.lizzy.rs Git - rust.git/blob - tests/ui/closures/2229_closure_analysis/deep-multilevel-struct.rs
Rollup merge of #106321 - compiler-errors:delayed-bug-backtrace, r=Nilstrieb
[rust.git] / tests / ui / closures / 2229_closure_analysis / deep-multilevel-struct.rs
1 // edition:2021
2
3 #![feature(rustc_attrs)]
4 #![allow(unused)]
5
6 #[derive(Debug)]
7 struct Point {
8     x: i32,
9     y: i32,
10 }
11 #[derive(Debug)]
12 struct Line {
13     p: Point,
14     q: Point
15 }
16 #[derive(Debug)]
17 struct Plane {
18     a: Line,
19     b: Line,
20 }
21
22 fn main() {
23     let mut p = Plane {
24         a: Line {
25             p: Point { x: 1,y: 2 },
26             q: Point { x: 3,y: 4 },
27         },
28         b: Line {
29             p: Point { x: 1,y: 2 },
30             q: Point { x: 3,y: 4 },
31         }
32     };
33
34     let c = #[rustc_capture_analysis]
35     //~^ ERROR: attributes on expressions are experimental
36     //~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
37     || {
38     //~^ ERROR: First Pass analysis includes:
39     //~| ERROR: Min Capture analysis includes:
40         let x = &p.a.p.x;
41         //~^ NOTE: Capturing p[(0, 0),(0, 0),(0, 0)] -> ImmBorrow
42         p.b.q.y = 9;
43         //~^ NOTE: Capturing p[(1, 0),(1, 0),(1, 0)] -> MutBorrow
44         //~| NOTE: p[] captured as MutBorrow here
45         println!("{:?}", p);
46         //~^ NOTE: Capturing p[] -> ImmBorrow
47         //~| NOTE: Min Capture p[] -> MutBorrow
48         //~| NOTE: p[] used here
49     };
50 }