summaryrefslogtreecommitdiffstats
path: root/tests/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-1.rs
blob: 3664d76c2038f2da3c93f3e9532801d94d4e6c06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// edition:2021

#[derive(Debug)]
struct Point {
    x: i32,
    y: i32,
}
fn main() {
    let mut p = Point {x: 1, y: 2 };

    let y = &mut p.y;
    let mut c = || {
    //~^ ERROR cannot borrow `p` as mutable more than once at a time
       let x = &mut p.x;
       println!("{:?}", p);
    };
    c();
    *y+=1;
}