]> git.lizzy.rs Git - rust.git/blob - tests/ui/closures/2229_closure_analysis/capture-analysis-4.rs
Auto merge of #107843 - bjorn3:sync_cg_clif-2023-02-09, r=bjorn3
[rust.git] / tests / ui / closures / 2229_closure_analysis / capture-analysis-4.rs
1 // edition:2021
2
3 #![feature(rustc_attrs)]
4
5 #[derive(Debug)]
6 struct Child {
7     c: String,
8     d: String,
9 }
10
11 #[derive(Debug)]
12 struct Parent {
13     b: Child,
14 }
15
16 fn main() {
17     let mut a = Parent { b: Child {c: String::new(), d: String::new()} };
18
19     let c = #[rustc_capture_analysis]
20     //~^ ERROR: attributes on expressions are experimental
21     //~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
22     || {
23     //~^ First Pass analysis includes:
24     //~| Min Capture analysis includes:
25         let _x = a.b;
26         //~^ NOTE: Capturing a[(0, 0)] -> ByValue
27         //~| NOTE: Min Capture a[(0, 0)] -> ByValue
28         println!("{:?}", a.b.c);
29         //~^ NOTE: Capturing a[(0, 0),(0, 0)] -> ImmBorrow
30     };
31 }