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