]> git.proxmox.com Git - rustc.git/blob - tests/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-2.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / closures / 2229_closure_analysis / diagnostics / borrowck / borrowck-2.rs
1 // edition:2021
2
3 #[derive(Debug)]
4 struct Point {
5 x: i32,
6 y: i32,
7 }
8 fn main() {
9 let mut p = Point {x: 1, y: 2 };
10
11 let y = &p.y;
12 let mut c = || {
13 //~^ ERROR cannot borrow `p` as mutable because it is also borrowed as immutable
14 println!("{:?}", p);
15 let x = &mut p.x;
16 };
17 c();
18 println!("{}", y);
19 }