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

#[derive(Debug)]
struct Point {
    x: String,
    y: String,
}
fn main() {
    let mut c = {
        let mut p = Point {x: "1".to_string(), y: "2".to_string() };
        || { //~ ERROR closure may outlive the current block, but it borrows `p`
           let x = &mut p.x;
           println!("{:?}", p);
        }
    };
    c();
}