]> git.proxmox.com Git - rustc.git/blob - src/test/ui/closures/2229_closure_analysis/run_pass/edition.rs
New upstream version 1.55.0+dfsg1
[rustc.git] / src / test / ui / closures / 2229_closure_analysis / run_pass / edition.rs
1 // edition:2021
2 // run-pass
3
4 // Test that edition 2021 enables disjoint capture by default.
5
6 struct Point {
7 x: i32,
8 y: i32,
9 }
10
11 fn main() {
12 let mut p = Point { x: 10, y: 10 };
13
14 let c = || {
15 println!("{}", p.x);
16 };
17
18 // `c` should only capture `p.x`, therefore mutating `p.y` is allowed.
19 let py = &mut p.y;
20
21 c();
22 *py = 20;
23 }